#include "wnd_widget.h"


#include "wnd_set.h"
#include <math.h>
#include "wnd_handle.h"
#include "wnd_api.h"


unsigned int WND_WIDGET_GetMiniguiColour(UI_COLOUR_E enUiColor)
{
	switch(enUiColor) {
		case UI_COLOR_BLACK_E:
			return COLOR_black;
		case UI_COLOR_LIGHTWHITE_E:
			return COLOR_lightwhite;
		case UI_COLOR_CYAN_E:
			return COLOR_cyan;
		case UI_COLOR_MAGENTA_E:
			return COLOR_magenta;
		case UI_COLOR_BLUE_E:
			return COLOR_blue;
		case UI_COLOR_YELLOW_E:
			return COLOR_yellow;
		case UI_COLOR_GREEN_E:
			return COLOR_green;
		case UI_COLOR_RED_E:
			return COLOR_red;
		case UI_COLOR_DARGRAY_E:
			return COLOR_darkgray;
		case UI_COLOR_LIGHTGRAY_E:
			return COLOR_lightgray;
		case UI_COLOR_DARKCYAN_E:
			return COLOR_darkcyan;
		case UI_COLOR_DARKMAGENTA_E:
			return COLOR_darkmagenta;
		case UI_COLOR_DARKBLUE_E:
			return COLOR_darkblue;
		case UI_COLOR_DARKYELLOW_E:
			return COLOR_darkyellow;
		case UI_COLOR_DARKGREEN_E:
			return COLOR_darkgreen;
		case UI_COLOR_DARKRED_E:
			return COLOR_darkred;
		case UI_COLOR_TRANSPARENT_E:
			//return COLOR_transparent;
			return 0;
		case UI_COLOR_ORANGE_E:
			//turn Pixel2DWORD(HDC_SCREEN, RGB2Pixel(HDC_SCREEN, 0xAA, 0x55, 0x00));
			return  RGB2Pixel(HDC_SCREEN, 0xAA, 0x55, 0x00);
		case UI_COLOR_INVALID_E:
			return COLOR_invalid;
		default:
			break;
	}
	return 0;
}

DWORD WND_WIDGET_GetColor(WND_WIDGET_S *pstWnd, UI_COLOUR_E enUiColor)
{
	unsigned int u32WndId = pstWnd->stCommon.stAttr.u32WndId;

	HDC u32Hdc = GetDC(u32WndId);
	DWORD u64FontColor;


	switch(enUiColor) {
		case UI_COLOR_BLACK_E:
			u64FontColor = Pixel2DWORD(u32Hdc, RGB2Pixel(u32Hdc, 0x00, 0x00, 0x00));
		break;
		case UI_COLOR_LIGHTWHITE_E:
			u64FontColor = Pixel2DWORD(u32Hdc, RGB2Pixel(u32Hdc, 0xFF, 0xFF, 0xFF));
		break;
		case UI_COLOR_CYAN_E:
			u64FontColor = Pixel2DWORD(u32Hdc, RGB2Pixel(u32Hdc, 0x80, 0xFF, 0xFF));
		break;
		case UI_COLOR_MAGENTA_E:
			u64FontColor = Pixel2DWORD(u32Hdc, RGB2Pixel(u32Hdc, 0xFF, 0x80, 0xFF));
		break;
		case UI_COLOR_BLUE_E:
			u64FontColor = Pixel2DWORD(u32Hdc, RGB2Pixel(u32Hdc, 0x00, 0x00, 0xFF));
		break;
		case UI_COLOR_YELLOW_E:
			u64FontColor = Pixel2DWORD(u32Hdc, RGB2Pixel(u32Hdc, 0xFF, 0xFF, 0x00));
		break;
		case UI_COLOR_GREEN_E:
			u64FontColor = Pixel2DWORD(u32Hdc, RGB2Pixel(u32Hdc, 0x00, 0xFF, 0x00));
		break;
		case UI_COLOR_RED_E:
			u64FontColor = Pixel2DWORD(u32Hdc, RGB2Pixel(u32Hdc, 0xFF, 0x00, 0x00));
		break;
		case UI_COLOR_DARGRAY_E:
			u64FontColor = Pixel2DWORD(u32Hdc, RGB2Pixel(u32Hdc, 0x80, 0x80, 0x80));
		break;
		case UI_COLOR_LIGHTGRAY_E:
			u64FontColor = Pixel2DWORD(u32Hdc, RGB2Pixel(u32Hdc, 0xC0, 0xC0, 0xC0));
		break;
		case UI_COLOR_DARKCYAN_E:
			u64FontColor = Pixel2DWORD(u32Hdc, RGB2Pixel(u32Hdc, 0x00, 0x80, 0x80));
		break;
		case UI_COLOR_DARKMAGENTA_E:
			u64FontColor = Pixel2DWORD(u32Hdc, RGB2Pixel(u32Hdc, 0x80, 0x00, 0xFF));
		break;
		case UI_COLOR_DARKBLUE_E:
			u64FontColor = Pixel2DWORD(u32Hdc, RGB2Pixel(u32Hdc, 0x00, 0x00, 0xA0));
		break;
		case UI_COLOR_DARKYELLOW_E:
			u64FontColor = Pixel2DWORD(u32Hdc, RGB2Pixel(u32Hdc, 0x80, 0x80, 0x00));
		break;
		case UI_COLOR_DARKGREEN_E:
			u64FontColor = Pixel2DWORD(u32Hdc, RGB2Pixel(u32Hdc, 0x00, 0x80, 0x00));
		break;
		case UI_COLOR_DARKRED_E:
			u64FontColor = Pixel2DWORD(u32Hdc, RGB2Pixel(u32Hdc, 0x80, 0x00, 0x00));
		break;
		case UI_COLOR_ORANGE_E:
			u64FontColor = Pixel2DWORD(u32Hdc, RGB2Pixel(u32Hdc, 0xAA, 0x55, 0x00));
		break;
		case UI_COLOR_TRANSPARENT_E:
			u64FontColor = 0;
		break;
		case UI_COLOR_INVALID_E:
			return 0;
		default:
			break;
	}
	ReleaseDC (u32Hdc);

	return u64FontColor;

}

int WND_WIDGET_SetFontcolor(WND_WIDGET_S *pstWnd, UI_COLOUR_E enUiColor)
{
	unsigned int u32WndId = pstWnd->stCommon.stAttr.u32WndId;

	HDC u32Hdc = GetDC(u32WndId);
	DWORD u64FontColor;

#if 0
	switch(enUiColor) {
		case UI_COLOR_BLACK_E:
			u64FontColor = Pixel2DWORD(u32Hdc, RGB2Pixel(u32Hdc, 0x00, 0x00, 0x00));
		break;
		case UI_COLOR_LIGHTWHITE_E:
			u64FontColor = Pixel2DWORD(u32Hdc, RGB2Pixel(u32Hdc, 0xFF, 0xFF, 0xFF));
		break;
		case UI_COLOR_CYAN_E:
			u64FontColor = Pixel2DWORD(u32Hdc, RGB2Pixel(u32Hdc, 0x80, 0xFF, 0xFF));
		break;
		case UI_COLOR_MAGENTA_E:
			u64FontColor = Pixel2DWORD(u32Hdc, RGB2Pixel(u32Hdc, 0xFF, 0x80, 0xFF));
		break;
		case UI_COLOR_BLUE_E:
			u64FontColor = Pixel2DWORD(u32Hdc, RGB2Pixel(u32Hdc, 0x00, 0x00, 0xFF));
		break;
		case UI_COLOR_YELLOW_E:
			u64FontColor = Pixel2DWORD(u32Hdc, RGB2Pixel(u32Hdc, 0xFF, 0xFF, 0x00));
		break;
		case UI_COLOR_GREEN_E:
			u64FontColor = Pixel2DWORD(u32Hdc, RGB2Pixel(u32Hdc, 0x00, 0xFF, 0x00));
		break;
		case UI_COLOR_RED_E:
			u64FontColor = Pixel2DWORD(u32Hdc, RGB2Pixel(u32Hdc, 0xFF, 0x00, 0x00));
		break;
		case UI_COLOR_DARGRAY_E:
			u64FontColor = Pixel2DWORD(u32Hdc, RGB2Pixel(u32Hdc, 0x80, 0x80, 0x80));
		break;
		case UI_COLOR_LIGHTGRAY_E:
			u64FontColor = Pixel2DWORD(u32Hdc, RGB2Pixel(u32Hdc, 0xC0, 0xC0, 0xC0));
		break;
		case UI_COLOR_DARKCYAN_E:
			u64FontColor = Pixel2DWORD(u32Hdc, RGB2Pixel(u32Hdc, 0x00, 0x80, 0x80));
		break;
		case UI_COLOR_DARKMAGENTA_E:
			u64FontColor = Pixel2DWORD(u32Hdc, RGB2Pixel(u32Hdc, 0x80, 0x00, 0xFF));
		break;
		case UI_COLOR_DARKBLUE_E:
			u64FontColor = Pixel2DWORD(u32Hdc, RGB2Pixel(u32Hdc, 0x00, 0x00, 0xA0));
		break;
		case UI_COLOR_DARKYELLOW_E:
			u64FontColor = Pixel2DWORD(u32Hdc, RGB2Pixel(u32Hdc, 0x80, 0x80, 0x00));
		break;
		case UI_COLOR_DARKGREEN_E:
			u64FontColor = Pixel2DWORD(u32Hdc, RGB2Pixel(u32Hdc, 0x00, 0x80, 0x00));
		break;
		case UI_COLOR_DARKRED_E:
			u64FontColor = Pixel2DWORD(u32Hdc, RGB2Pixel(u32Hdc, 0x80, 0x00, 0x00));
		break;
		case UI_COLOR_ORANGE_E:
			u64FontColor = Pixel2DWORD(u32Hdc, RGB2Pixel(u32Hdc, 0xAA, 0x55, 0x00));
		break;
		case UI_COLOR_TRANSPARENT_E:
			u64FontColor = 0;
		break;
		case UI_COLOR_INVALID_E:
			return 0;
		default:
			break;
	}
#endif
	u64FontColor = WND_WIDGET_GetColor(pstWnd, enUiColor);

	if(pstWnd->enType == WND_WIDGET_TYPE_BUTTON_E ||
		pstWnd->enType == WND_WIDGET_TYPE_MULTI_BUTTON_E ||
		pstWnd->enType == WND_WIDGET_TYPE_RADIO_BUTTON_E) {

		SetWindowElementAttr(u32WndId, WE_FGC_THREED_BODY, u64FontColor);

	} else {

		SetWindowElementAttr(u32WndId, WE_FGC_WINDOW, u64FontColor);
	}

	//SetWindowElementAttr(u32WndId, WE_FGC_THREED_BODY, u64FontColor);

	//SetWindowElementAttr(u32WndId, WE_FGC_WINDOW, u64FontColor);

	//SetWindowElementAttr(u32WndId, WE_METRICS_SCROLLBAR, u64FontColor);

	ReleaseDC (u32Hdc);
	return 0;
}


char *MINIGUI_GET_CtrlClassName(WND_WIDGET_TYPE_E enType)
{
	switch(enType) {
		case WND_WIDGET_TYPE_MAIN_E:
		case WND_WIDGET_TYPE_DLG_E:
			return NULL;

		case WND_WIDGET_TYPE_BUTTON_E:         //!<	创建一个按钮
		case WND_WIDGET_TYPE_PICTURE_BUTTON_E: //!<	创建一个图标按钮
		case WND_WIDGET_TYPE_MULTI_BUTTON_E:   //!<	创建一个复选按钮
		case WND_WIDGET_TYPE_RADIO_BUTTON_E:   //!<	创建一个复选按钮
			return CTRL_BUTTON;
		case WND_WIDGET_TYPE_STATIC_PICTURE_E:
		case WND_WIDGET_TYPE_STATIC_TEXT_E:
			return CTRL_STATIC;
		case WND_WIDGET_TYPE_SCROLL_E:
			return CTRL_SCROLLWND;
		case WND_WIDGET_TYPE_ATTR_LIST_E:
			return CTRL_PROPSHEET;
		case WND_WIDGET_TYPE_EDIT_E:
			return CTRL_EDIT;
		case WND_WIDGET_TYPE_MENU_BUTTON_E:
			return CTRL_MENUBUTTON;
		case WND_WIDGET_TYPE_DROP_DOWN_E:
			return CTRL_COMBOBOX;
		case WND_WIDGET_TYPE_ICON_VIEW_E:
			return CTRL_ICONVIEW;
		default:
			return NULL;
	}
	return NULL;
}





int WND_WIDGET_StlySwitch(WND_WIDGET_S *pstWnd, unsigned int u32Parent)
{
	WIDGET_COMMON_S *pstCommon = &pstWnd->stCommon;
	WND_ATTR_S *pstAttr = &pstCommon->stAttr;
	//WND_FOPS_S *pstFops = &pstCommon->stFops;


	/* 风格转换*/
	if(pstWnd->enType != WND_WIDGET_TYPE_MAIN_E) {
		if(pstAttr->bShowNow) {
			pstAttr->u64Style |= WS_VISIBLE;
		}
	}

	if(pstAttr->bBorder) {
		pstAttr->u64Style |= WS_BORDER | WS_THICKFRAME;
	}

	if(pstAttr->bCaption) {
		pstAttr->u64Style |= WS_CAPTION;
	}

	/* 如果不是主窗口则风格为子窗口*/
	if(pstWnd->enType != WND_WIDGET_TYPE_MAIN_E) {
		pstAttr->u64Style |= WS_CHILD;
		pstAttr->u32ParentWndId = u32Parent;
	} else {
		if(u32Parent > 0) {
			pstAttr->u32ParentWndId = u32Parent;
		}
	}



	switch(pstWnd->enType) {

		case WND_WIDGET_TYPE_BUTTON_E: {

			if(pstWnd->unPrivate.stButton.bMultLine) {
				pstAttr->u64Style |= BS_MULTLINE;
			}

		}
		break;
		case WND_WIDGET_TYPE_PICTURE_BUTTON_E: {
			if(pstWnd->unPrivate.stPictureButton.s32RealSizeImage == 1) {
				pstAttr->u64Style |= BS_REALSIZEIMAGE;
			}
			pstAttr->u64Style |= BS_BITMAP;
		}
		break;
		case WND_WIDGET_TYPE_MULTI_BUTTON_E: {
			if(pstWnd->unPrivate.stMultiButton.s32AutoCheck == 0) {
				pstAttr->u64Style |= BS_CHECKBOX;
			} else if(pstWnd->unPrivate.stMultiButton.s32AutoCheck == 1) {
				pstAttr->u64Style |= BS_AUTOCHECKBOX;
			}else if(pstWnd->unPrivate.stMultiButton.s32AutoCheck == 2) {
				pstAttr->u64Style |= BS_3STATE;
			}else if(pstWnd->unPrivate.stMultiButton.s32AutoCheck == 3) {
				pstAttr->u64Style |= BS_AUTO3STATE;
			}

			if(pstWnd->unPrivate.stMultiButton.s32LeftText == 1) {
				pstAttr->u64Style |= BS_LEFTTEXT ;
			}
		}
		break;
		case WND_WIDGET_TYPE_RADIO_BUTTON_E: {
			if(pstWnd->unPrivate.stRadioButton.s32AutoCheck == 0) {
				pstAttr->u64Style |= BS_RADIOBUTTON;
			} else if(pstWnd->unPrivate.stRadioButton.s32AutoCheck == 1) {
				pstAttr->u64Style |= BS_AUTORADIOBUTTON;
			}

			if(pstWnd->unPrivate.stRadioButton.s32LeftText == 1) {
				pstAttr->u64Style |= BS_LEFTTEXT;
			}
			if(pstWnd->unPrivate.stRadioButton.s32GroupSta == 1) {
				pstAttr->u64Style |= WS_GROUP;
			}
			if(pstWnd->unPrivate.stRadioButton.s32PushLike == 1){
				pstAttr->u64Style |= BS_PUSHLIKE;
			}
		}
		break;
		case WND_WIDGET_TYPE_STATIC_PICTURE_E: {
			//pstAttr->u32WndId = MINI_INTF_CreateStaticPictureWnd();

		}
		break;
		case WND_WIDGET_TYPE_STATIC_TEXT_E: {


		}
		break;
		case WND_WIDGET_TYPE_SCROLL_E: {


		}
		break;

		case WND_WIDGET_TYPE_ATTR_LIST_E: {
			//pstAttr->u32WndId = WND_CREATE_AttrPage();
		}
		case WND_WIDGET_TYPE_DLG_E: {

		}
		break;
		default:
			//QLOG(ERR, "非法控件，无法创建\n");
			break;
	}
	return 0;
}







UI_COLOUR_E WND_WIDGET_GetBkColour(WND_WIDGET_S *pstWnd)
{
	UI_COLOUR_E enSetBkColor;
	WND_WIDGET_S *pstParentWnd = NULL;

	if(NULL == pstWnd) {
		QLOG(ERR, "部件的句柄为空，使用默认背景风格\n");
		enSetBkColor = stGlbMainWndHandle.enDefaultBkColour;
		return enSetBkColor;
	}

	/* 选择背景风格*/
	if(pstWnd->stCommon.stAttr.enBkColor == UI_COLOR_DEFAULT_E) {
		/* 如果颜色是默认颜色，则返回全局定义的默认色颜色*/
		enSetBkColor = stGlbMainWndHandle.enDefaultBkColour;
	} else if( pstWnd->stCommon.stAttr.enBkColor == UI_COLOR_PARENT_E) {
		/* 如果是主窗口则直接使用默认背景颜色*/
		if(pstWnd->enType == WND_WIDGET_TYPE_MAIN_E) {
			enSetBkColor = stGlbMainWndHandle.enDefaultBkColour;
		} else {
			pstParentWnd = (WND_WIDGET_S *)GetWindowAdditionalData(pstWnd->stCommon.stAttr.u32ParentWndId);
			if(pstParentWnd) {
				//QLOG(TDBG, "[%s] 父窗口背景风格[%u] 父窗口为[%s]\n", pstWnd->stCommon.stAttr.s8Name,
				//		pstParentWnd->stCommon.stAttr.enBkColor, pstParentWnd->stCommon.stAttr.s8Name);
				if(pstParentWnd->stCommon.stAttr.enBkColor == UI_COLOR_PARENT_E) {
					enSetBkColor = WND_WIDGET_GetBkColour(pstParentWnd);
				} else {
					enSetBkColor = pstParentWnd->stCommon.stAttr.enBkColor;
				}
			} else {
				QLOG(WRN, "未找到 [%s] 的父窗口私有数据， 使用默认背景颜色\n", pstWnd->stCommon.stAttr.s8Name);
				enSetBkColor = stGlbMainWndHandle.enDefaultBkColour;
				//GetParent(pstWnd->stCommon.stAttr.u32ParentWndId);
				//enSetBkColor = WND_WIDGET_GetBkColour(pstParentWnd);
			}
		}
	}else {
		enSetBkColor = pstWnd->stCommon.stAttr.enBkColor;
	}
	return enSetBkColor;
}

/*!
 * 初始化字体
 * @return  返回初始化后的字体
 * @param pstFont 要初始化的字体
 * @see
 */
LOGFONT * WND_WIDGET_InitFont(WND_WIDGET_FONT_S *pstFont)
{
	if(pstFont->s32FontSize > 0) {
		pstFont->pstFont = MINI_INTF_CreateLogFontUtf8(pstFont->s32FontSize);
	} else {
		return NULL;
	}
	return pstFont->pstFont;
}

/*!
 * 销毁字体
 * @param pstFont 要销毁的字体
 * @see
 */
void WND_WIDGET_DeInitFont(WND_WIDGET_FONT_S *pstFont)
{
	MINI_INTF_DestroyLogFont(pstFont->pstFont);
}

PLOGFONT WND_WIDGET_GetWndFont(WND_WIDGET_S *pstWnd)
{
	//int s32FontSize;
	WND_WIDGET_S *pstParentWnd = NULL;
	PLOGFONT pstFont = NULL;

	if(NULL == pstWnd) {
		QLOG(ERR, "部件的句柄为空，使用默认背景风格\n");
		//s32FontSize = stGlbMainWndHandle.s32DefaultFontSize;
		return stGlbMainWndHandle.stDefaultFont.pstFont;
	}

	/* 选择背景风格*/
	if(pstWnd->stCommon.stAttr.stFont.s32FontSize == 0) {
		/* 如果颜色是默认颜色，则返回全局定义的默认色颜色*/
		//s32FontSize = stGlbMainWndHandle.s32DefaultFontSize;
		pstFont = stGlbMainWndHandle.stDefaultFont.pstFont;

	} else if( pstWnd->stCommon.stAttr.stFont.s32FontSize == -1) {


		pstParentWnd = (WND_WIDGET_S *)GetWindowAdditionalData(pstWnd->stCommon.stAttr.u32ParentWndId);
		if(pstParentWnd) {
			if(pstParentWnd->stCommon.stAttr.stFont.s32FontSize == -1) {
				pstFont = WND_WIDGET_GetWndFont(pstParentWnd);
			} else {
				//s32FontSize = pstParentWnd->stCommon.stAttr.stFont.s32FontSize;
				pstFont = WND_WIDGET_InitFont(&pstParentWnd->stCommon.stAttr.stFont);
			}
		} else {
			QLOG(WRN, "未找到 [%s] 的父窗口私有数据， 使用默认背景颜色\n", pstWnd->stCommon.stAttr.s8Name);
			pstFont = stGlbMainWndHandle.stDefaultFont.pstFont;
		}
	}else {
		pstFont = WND_WIDGET_InitFont(&pstWnd->stCommon.stAttr.stFont);

	}
	return pstFont;
}


UI_COLOUR_E WND_WIDGET_GetFontColour(WND_WIDGET_S *pstWnd)
{
	UI_COLOUR_E enSetBkColor;
	WND_WIDGET_S *pstParentWnd = NULL;

	if(NULL == pstWnd) {
		QLOG(ERR, "部件的句柄为空，使用默认背景风格\n");
		enSetBkColor = stGlbMainWndHandle.stDefaultFont.enFontColor;
		return enSetBkColor;
	}


	/* 选择背景风格*/
	if(pstWnd->stCommon.stAttr.stFont.enFontColor == UI_COLOR_DEFAULT_E) {
		/* 如果颜色是默认颜色，则返回全局定义的默认色颜色*/
		enSetBkColor = stGlbMainWndHandle.stDefaultFont.enFontColor;
	} else if( pstWnd->stCommon.stAttr.stFont.enFontColor == UI_COLOR_PARENT_E) {
		/* 如果是主窗口则直接使用默认背景颜色*/
		if(pstWnd->enType == WND_WIDGET_TYPE_MAIN_E) {
			enSetBkColor = stGlbMainWndHandle.stDefaultFont.enFontColor;
		} else {
			pstParentWnd = (WND_WIDGET_S *)GetWindowAdditionalData(pstWnd->stCommon.stAttr.u32ParentWndId);
			if(pstParentWnd) {
				//QLOG(TDBG, "[%s] 父窗口背景风格[%u] 父窗口为[%s]\n", pstWnd->stCommon.stAttr.s8Name,
				//		pstParentWnd->stCommon.stAttr.enBkColor, pstParentWnd->stCommon.stAttr.s8Name);
				if(pstParentWnd->stCommon.stAttr.stFont.enFontColor == UI_COLOR_PARENT_E) {
					enSetBkColor = WND_WIDGET_GetBkColour(pstParentWnd);
				} else {
					enSetBkColor = pstParentWnd->stCommon.stAttr.stFont.enFontColor;
				}
			} else {
				QLOG(WRN, "未找到 [%s] 的父窗口私有数据， 使用默认背景颜色\n", pstWnd->stCommon.stAttr.s8Name);
				enSetBkColor = stGlbMainWndHandle.stDefaultFont.enFontColor;
				//GetParent(pstWnd->stCommon.stAttr.u32ParentWndId);
				//enSetBkColor = WND_WIDGET_GetBkColour(pstParentWnd);
			}
		}
	}else {
		enSetBkColor = pstWnd->stCommon.stAttr.stFont.enFontColor;
	}

	return enSetBkColor;
}





void WND_WIDGET_EnbleFontSize(WND_WIDGET_S *pstWnd)
{
	SetWindowFont(pstWnd->stCommon.stAttr.u32WndId, WND_WIDGET_GetWndFont(pstWnd));
}

void WND_WIDGET_EnbleBkColour(WND_WIDGET_S *pstWnd)
{
	SetWindowBkColor(pstWnd->stCommon.stAttr.u32WndId, WND_WIDGET_GetMiniguiColour(WND_WIDGET_GetBkColour(pstWnd)));
	//DWORD u64FontColor = WND_WIDGET_GetColor(pstWnd, WND_WIDGET_GetBkColour(pstWnd));
	//SetWindowElementAttr(pstWnd->stCommon.stAttr.u32WndId, WE_FGC_WINDOW, u64FontColor);


}

void WND_WIDGET_EnbleFontColour(WND_WIDGET_S *pstWnd)
{
	//WND_WIDGET_SetFontcolor(pstWnd->stCommon.stAttr.u32WndId, WND_WIDGET_GetFontColour(pstWnd));
	WND_WIDGET_SetFontcolor(pstWnd, WND_WIDGET_GetFontColour(pstWnd));
}

void WND_WIDGET_EnbleStly(WND_WIDGET_S *pstWnd)
{
	WND_WIDGET_EnbleBkColour(pstWnd);
	WND_WIDGET_EnbleFontSize(pstWnd);
	WND_WIDGET_EnbleFontColour(pstWnd);

}



unsigned int WND_WIDGET_CreateMainWnd(unsigned long u64Style, unsigned long u64ExStyle,
									int (*MainWndMsgProc)(unsigned int u32Wnd, int s32Message, unsigned int u32Param, unsigned long u64Param),
									int s32WndX, int s32WndY, int s32WndWidth, int s32WndHeight,
									UI_COLOUR_E enBkColor,
									unsigned long u64AddData,
									HWND  hHosting,
									int s32CmdShow)
{
	//BOOL u8Ret;
	unsigned int u32MainWnd;
	MAINWINCREATE stCreateInfo;

	if(MainWndMsgProc == NULL) {
		QLOG(ERR, "主窗口的回调函数不能为空\n");
		return 0;
	}
	if(s32WndWidth == 0 || s32WndHeight == 0) {
		QLOG(ERR, "主窗口的长宽必须大于0 s32WndWidth[%d] s32WndHeight[%d]\n", s32WndWidth, s32WndHeight);
		return 0;
	}

	UI_COLOUR_E enSetBkColor;
	/* 选择背景风格*/
	if(enBkColor == UI_COLOR_DEFAULT_E || enBkColor == UI_COLOR_PARENT_E) {
		enSetBkColor = stGlbMainWndHandle.enDefaultBkColour;
	} else {
		enSetBkColor = enBkColor;
	}

	stCreateInfo.dwStyle = u64Style;
	//stCreateInfo.dwExStyle = u64ExStyle | WS_EX_AUTOSECONDARYDC;
	stCreateInfo.dwExStyle = u64ExStyle;
	stCreateInfo.spCaption = "";
	stCreateInfo.hMenu = 0;
	stCreateInfo.hCursor = GetSystemCursor(0);
	stCreateInfo.hIcon = 0;
	stCreateInfo.MainWindowProc = MainWndMsgProc;
	stCreateInfo.lx = s32WndX;
	stCreateInfo.ty = s32WndY;
	stCreateInfo.rx = s32WndWidth;
	stCreateInfo.by = s32WndHeight;
	stCreateInfo.iBkColor = WND_WIDGET_GetMiniguiColour(enBkColor);
	stCreateInfo.dwAddData = u64AddData;
	//stCreateInfo.hHosting = hHosting;
	stCreateInfo.hHosting = HWND_DESKTOP;

	u32MainWnd = CreateMainWindow(&stCreateInfo);
	if (u32MainWnd == HWND_INVALID) {
		QLOG(ERR, "主界面创建失败\n");
		return -1;
	}
/*
	u8Ret = ShowWindow(u32MainWnd, s32CmdShow);
	if(FALSE == u8Ret) {
		QLOG(ERR, "MINI_API_ShowOrHideWindow failed\n");
		return -1;
	} else if(TRUE == u8Ret) {
		QLOG(TDBG, "成功显示窗口\n");
	}
*/


	return u32MainWnd;
}

static void * WND_WIDGET_CreateMain(void *pArg)
{

	WND_WIDGET_S *pstMainWnd = (WND_WIDGET_S *)pArg;

	int s32CmdShow;
	unsigned int u32WndId;
	WIDGET_COMMON_S *pstCommon = &pstMainWnd->stCommon;
	WND_ATTR_S *pstAttr = &pstCommon->stAttr;
	//WND_FOPS_S *pstFops = &pstCommon->stFops;

	if(pstMainWnd->stCommon.stAttr.bShowNow) {
		s32CmdShow = SW_SHOWNORMAL;
	} else {
		s32CmdShow = SW_HIDE;
	}

	unsigned int u32WndX = (pstAttr->u32WndX * stGlbMainWndHandle.s32ScreenWidth) / UI_COORD_MAX;
	unsigned int u32WndY = (pstAttr->u32WndY * stGlbMainWndHandle.s32ScreenHeight) / UI_COORD_MAX;
	unsigned int u32WndWidth = (pstAttr->u32WndHeight * stGlbMainWndHandle.s32ScreenWidth) / UI_COORD_MAX;
	unsigned int u32WndHeight = (pstAttr->u32WndHeight * stGlbMainWndHandle.s32ScreenHeight) / UI_COORD_MAX;


	pstAttr->u32WndId = WND_WIDGET_CreateMainWnd(pstAttr->u64Style,
										pstAttr->u64ExStyle,
										pstMainWnd->stCommon.stFops.CallBack,
										u32WndX,
										u32WndY,
										u32WndWidth,
										u32WndHeight,
										pstAttr->enBkColor,
										(DWORD)pstMainWnd,
										pstAttr->u32ParentWndId,
										s32CmdShow);

	sem_post(&pstMainWnd->unPrivate.stMain.stWait);
	MSG stMsg;
	u32WndId = pstAttr->u32WndId;
	while(GetMessage(&stMsg, u32WndId)) {

		TranslateMessage (&stMsg);
		DispatchMessage (&stMsg);
		//memset(&stMsg, 0, sizeof(stMsg));

	}
	QLOG(TDBG, "退出窗口\n");

	MainWindowThreadCleanup(u32WndId);

	//MINI_INTF_StartMainWndProc(pstAttr->u32WndId);

	return NULL;

}








/*!
 * 创建一个了列表按钮菜单窗口
 * @return	创建窗口的id -1 失败
 * @param u64Style   窗口风格 和普通的窗口一样
 * @param s32Id 创建的菜单消息ID 发送消息时用到
 * @param s32WndX 窗口的X坐标
 * @param s32WndY 窗口的Y坐标
 * @param s32WndWidth 窗口的宽度
 * @param s32WndHeight 窗口的高度
 * @param pstMenuList 创建的列表按钮菜单的消息
 * @param s32MenuListNum pstMenuList的个数
 * @param u32ParentWnd 窗口的父窗口ID 需要在哪个窗口上面建立按钮窗口
 * @param MenuListCallBack 回调函数
 * @param s32NewBkColor 按钮的颜色
 * @param pstFont 按钮字体 销毁窗口的时候需要自己销毁
 */
HWND WND_WIDGET_CreateListMenu2(DWORD u32Style, int s32Id,
									int s32WinX, int s32WndY, int s32WndWidth, int s32WndHeight,
									HWND u32ParentWnd,
									CTRLDATA *pstMenuList, int s32MenuListNum,
									int s32ButtonHight,
									DWORD u64AddDate,
									int (*MenuListCallBack)(HWND hWnd, int message, WPARAM wParam, LPARAM lParam),
									int s32Type)
{

	//int s32Num;
	HWND WndMenuList;
	int s32SetWndHeight;

	if(pstMenuList == NULL) {
		QLOG(ERR, "列表菜单参数为空\n");
		return -1;
	}
	if(MenuListCallBack == NULL) {
		QLOG(ERR, "回调函数为空\n");
		return -1;
	}

	s32SetWndHeight = s32WndHeight;
#if 0
	if(s32Type == 1) {

	} else if(s32Type == 2) {
		for(s32Num = 0; s32Num < s32MenuListNum; s32Num++) {
			/* 计算列表里面按钮的位置*/
			pstMenuList[s32Num].x = 0;
			pstMenuList[s32Num].y = s32Num*s32ButtonHight;
			pstMenuList[s32Num].w = s32WndWidth;
			pstMenuList[s32Num].h = s32ButtonHight;
		}
	} else if(s32Type == 3) {
		s32SetWndHeight = 0;
		for(s32Num = 0; s32Num < s32MenuListNum; s32Num++) {
			/* 计算列表里面按钮的位置*/

			pstMenuList[s32Num].x = 0;
			pstMenuList[s32Num].y = s32Num*s32ButtonHight;
			pstMenuList[s32Num].w = s32WndWidth;
			pstMenuList[s32Num].h = s32ButtonHight+10;
			s32SetWndHeight += pstMenuList[s32Num].h;
		}
		//s32SetWndHeight += ;
	} else {
		QLOG(TDBG, "列表控件未指定排列风格\n");
	}
#endif

	if((s32WndY + s32SetWndHeight) > stGlbMainWndHandle.s32ScreenHeight) {
		s32SetWndHeight = stGlbMainWndHandle.s32ScreenHeight - s32WndY;
	}
	WndMenuList = MINI_INTF_CreateScrollCtrlWnd(u32Style, s32Id,
									s32WinX, s32WndY, s32WndWidth, s32SetWndHeight,
									u32ParentWnd,
									MenuListCallBack,u64AddDate);




	/* 设置字体*/
									/*
	if(pstFont) {
		SetWindowFont(WndMenuList, pstFont);
	}*/

	MINI_INTF_ScrollCtrlSetCententSize(WndMenuList, s32WndWidth, s32ButtonHight* s32MenuListNum);
	//MINI_INTF_ScrollCtrlSetCententSize(WndMenuList, 0, s32ButtonHight* s32MenuListNum);


	MINI_INTF_ScrollCtrlAdd(WndMenuList, pstMenuList, s32MenuListNum);

	return WndMenuList;
}



unsigned int WND_WIDGET_CreateButton(WND_WIDGET_S *pstWnd,
									unsigned int u32WndX,
									unsigned int u32WndY,
									unsigned int u32WndWidth,
									unsigned int u32WndHeight)
{
	WIDGET_COMMON_S *pstCommon = &pstWnd->stCommon;
	WND_ATTR_S *pstAttr = &pstCommon->stAttr;
	WND_FOPS_S *pstFops = &pstCommon->stFops;

	if(pstWnd->unPrivate.stButton.bMultLine) {
		pstAttr->u64Style |= BS_MULTLINE;
	}

	pstAttr->u32WndId = MINI_INTF_CreateButtonWnd(pstAttr->s8Name,
								pstAttr->u64Style,
								pstAttr->u32Id,
								u32WndX,
								u32WndY,
								u32WndWidth,
								u32WndHeight,
								pstAttr->u32ParentWndId,
								(DWORD)pstWnd,
								pstFops->CallBackByVoid);



	return pstAttr->u32WndId;
}



unsigned int WND_WIDGET_CreatePictureButton(WND_WIDGET_S *pstWnd,
									unsigned int u32WndX,
									unsigned int u32WndY,
									unsigned int u32WndWidth,
									unsigned int u32WndHeight)
{
	WIDGET_COMMON_S *pstCommon = &pstWnd->stCommon;
	WND_ATTR_S *pstAttr = &pstCommon->stAttr;
	WND_FOPS_S *pstFops = &pstCommon->stFops;


	if(pstWnd->unPrivate.stPictureButton.s32RealSizeImage == 1) {
		pstAttr->u64Style |= BS_REALSIZEIMAGE;
	}
	pstAttr->u64Style |= BS_BITMAP;

	HDC hdc = GetDC(pstWnd->stCommon.stAttr.u32ParentWndId);
	LoadBitmap(hdc, &pstWnd->unPrivate.stPictureButton.stBitMap, pstWnd->unPrivate.stPictureButton.s8MapPath);

	pstAttr->u32WndId = MINI_INTF_CreateButtonWnd(pstAttr->s8Name,
								pstAttr->u64Style,
								pstAttr->u32Id,
								u32WndX,
								u32WndY,
								u32WndWidth,
								u32WndHeight,
								pstAttr->u32ParentWndId,
								(DWORD)&pstWnd->unPrivate.stPictureButton.stBitMap, //(DWORD)pstWnd,
								pstFops->CallBackByVoid);

	ReleaseDC(hdc);

	return pstAttr->u32WndId;
}

void WND_WIDGET_DestroyPictureButton(WND_WIDGET_S *pstWnd)
{
	UnloadBitmap (&pstWnd->unPrivate.stPictureButton.stBitMap);
}




unsigned int WND_WIDGET_CreateMultiButton(WND_WIDGET_S *pstWnd,
									unsigned int u32WndX,
									unsigned int u32WndY,
									unsigned int u32WndWidth,
									unsigned int u32WndHeight)
{
	WIDGET_COMMON_S *pstCommon = &pstWnd->stCommon;
	WND_ATTR_S *pstAttr = &pstCommon->stAttr;
	WND_FOPS_S *pstFops = &pstCommon->stFops;

	if(pstWnd->unPrivate.stMultiButton.s32AutoCheck == 0) {
		pstAttr->u64Style |= BS_CHECKBOX;
	} else if(pstWnd->unPrivate.stMultiButton.s32AutoCheck == 1) {
		pstAttr->u64Style |= BS_AUTOCHECKBOX;
	}else if(pstWnd->unPrivate.stMultiButton.s32AutoCheck == 2) {
		pstAttr->u64Style |= BS_3STATE;
	}else if(pstWnd->unPrivate.stMultiButton.s32AutoCheck == 3) {
		pstAttr->u64Style |= BS_AUTO3STATE;
	}

	if(pstWnd->unPrivate.stMultiButton.s32LeftText == 1) {
		pstAttr->u64Style |= BS_LEFTTEXT ;
	}

	pstAttr->u32WndId = MINI_INTF_CreateButtonWnd(pstAttr->s8Name,
								pstAttr->u64Style,
								pstAttr->u32Id,
								u32WndX,
								u32WndY,
								u32WndWidth,
								u32WndHeight,
								pstAttr->u32ParentWndId,
								(DWORD)pstWnd,
								pstFops->CallBackByVoid);


	return pstAttr->u32WndId;
}

unsigned int WND_WIDGET_CreateRadioButton(WND_WIDGET_S *pstWnd,
									unsigned int u32WndX,
									unsigned int u32WndY,
									unsigned int u32WndWidth,
									unsigned int u32WndHeight)
{
	WIDGET_COMMON_S *pstCommon = &pstWnd->stCommon;
	WND_ATTR_S *pstAttr = &pstCommon->stAttr;
	WND_FOPS_S *pstFops = &pstCommon->stFops;

	if(pstWnd->unPrivate.stRadioButton.s32AutoCheck == 0) {
		pstAttr->u64Style |= BS_RADIOBUTTON;
	} else if(pstWnd->unPrivate.stRadioButton.s32AutoCheck == 1) {
		pstAttr->u64Style |= BS_AUTORADIOBUTTON;
	}

	if(pstWnd->unPrivate.stRadioButton.s32LeftText == 1) {
		pstAttr->u64Style |= BS_LEFTTEXT;
	}
	if(pstWnd->unPrivate.stRadioButton.s32GroupSta == 1) {
		pstAttr->u64Style |= WS_GROUP;
	}
	if(pstWnd->unPrivate.stRadioButton.s32PushLike == 1){
		pstAttr->u64Style |= BS_PUSHLIKE;
	}

	pstAttr->u32WndId = MINI_INTF_CreateButtonWnd(pstAttr->s8Name,
								pstAttr->u64Style,
								pstAttr->u32Id,
								u32WndX,
								u32WndY,
								u32WndWidth,
								u32WndHeight,
								pstAttr->u32ParentWndId,
								(DWORD)pstWnd,
								pstFops->CallBackByVoid);


	return pstAttr->u32WndId;
}



unsigned int WND_WIDGET_CreateStaticPictureWnd(WND_WIDGET_S *pstWnd,
									unsigned int u32WndX,
									unsigned int u32WndY,
									unsigned int u32WndWidth,
									unsigned int u32WndHeight)
{
	unsigned int u32WndId;

	HDC u32Hdc = GetDC(pstWnd->stCommon.stAttr.u32ParentWndId);

	LoadBitmap(u32Hdc, &pstWnd->unPrivate.stStaticPicture.stBitMap , pstWnd->unPrivate.stStaticPicture.s8MapPath);

	pstWnd->stCommon.stAttr.u64Style |= SS_BITMAP;

	if(pstWnd->unPrivate.stStaticPicture.bNotify) {
		pstWnd->stCommon.stAttr.u64Style |= SS_NOTIFY;
	}

	u32WndId = MINI_INTF_CreateWnd(CTRL_STATIC,
									pstWnd->stCommon.stAttr.s8Name,
									pstWnd->stCommon.stAttr.u64Style,
									pstWnd->stCommon.stAttr.u32Id,
									u32WndX, u32WndY, u32WndWidth, u32WndHeight,
									pstWnd->stCommon.stAttr.u32ParentWndId,
									(DWORD)&pstWnd->unPrivate.stStaticPicture.stBitMap,
									pstWnd->stCommon.stFops.CallBackByVoid);

	SetWindowAdditionalData(u32WndId, (DWORD)pstWnd);
	ReleaseDC(u32Hdc);

	return u32WndId;

}




unsigned int WND_WIDGET_CreateListMenu(WND_WIDGET_S *pstWnd,
												int s32WinX,
												int s32WndY,
												int s32WndWidth,
												int s32WndHeight)
{
	WND_WIDGET_LIST_MENU_S *pstListMenu = &pstWnd->unPrivate.stListMenu;
	WND_ATTR_S *pstAttr = NULL;
	WND_FOPS_S *pstFops = NULL;

	int s32Num;
	int s32ChildCtrlHight = 0;
	unsigned int u32WndId;

/*
	if(pstWnd->s32WidgetNum <= 0) {
		QLOG(ERR, "列表控件子控件数量出错 [%d]\n", pstWnd->s32WidgetNum);
		return -1;
	}
*/

	//pstListMenu->pstFont = MINI_INTF_CreateLogFontUtf8(pstListMenu->s32FontSize);


	if(pstWnd->pstWidget == NULL) {
		QLOG(WRN, "列表控件子控件为空\n");
		//goto WND_CREATE_ListMenuErr;
	}

	pstListMenu->s32MenuListNum = pstWnd->s32WidgetNum;

	pstListMenu->pstMenuList = (CTRLDATA *)malloc(sizeof(CTRLDATA) * pstListMenu->s32MenuListNum);
	memset(pstListMenu->pstMenuList, 0 , sizeof(CTRLDATA) * pstListMenu->s32MenuListNum);

	/* 实际控件高度*/
	s32ChildCtrlHight = (pstListMenu->u32Ctrlheight*s32WndHeight)/UI_COORD_MAX;

	for(s32Num = 0; s32Num < pstWnd->s32WidgetNum; s32Num++) {
		pstAttr = &pstWnd->pstWidget[s32Num].stCommon.stAttr;

		pstListMenu->pstMenuList[s32Num].class_name = MINIGUI_GET_CtrlClassName(pstWnd->pstWidget[s32Num].enType);

		pstListMenu->pstMenuList[s32Num].dwStyle = pstAttr->u64Style;
		pstListMenu->pstMenuList[s32Num].dwExStyle = pstAttr->u64ExStyle;
#if 1


		if(pstListMenu->s32ChildArray == 1) {

			pstListMenu->pstMenuList[s32Num].x = ((pstAttr->u32WndX)* s32WndWidth) / UI_COORD_MAX;

			pstListMenu->pstMenuList[s32Num].y = ((pstAttr->u32WndY) * s32WndHeight) / UI_COORD_MAX;

			pstListMenu->pstMenuList[s32Num].w = ((pstAttr->u32WndHeight) * s32WndWidth) / UI_COORD_MAX;

			pstListMenu->pstMenuList[s32Num].h = ((pstAttr->u32WndHeight) * s32WndHeight) / UI_COORD_MAX;

		} else if(pstListMenu->s32ChildArray == 2) {

			pstListMenu->pstMenuList[s32Num].x = ((0 + pstWnd->unPrivate.stListMenu.s32Left)* s32WndHeight) / UI_COORD_MAX;

			pstListMenu->pstMenuList[s32Num].y = s32Num * s32ChildCtrlHight + ((pstWnd->unPrivate.stListMenu.s32Top * s32ChildCtrlHight) / UI_COORD_MAX);

			pstListMenu->pstMenuList[s32Num].w = s32WndWidth - ((pstWnd->unPrivate.stListMenu.s32Right +
									pstWnd->unPrivate.stListMenu.s32Left) * s32WndWidth) / UI_COORD_MAX;

			pstListMenu->pstMenuList[s32Num].h = s32ChildCtrlHight -
									((pstWnd->unPrivate.stListMenu.s32Bottom +
									pstWnd->unPrivate.stListMenu.s32Top) * s32WndHeight) / UI_COORD_MAX;
		} else {
			QLOG(TDBG, "列表控件未指定排列风格\n");
		}





#if 0

		pstListMenu->pstMenuList[s32Num].x = ((pstAttr->u32WndX +
								pstWnd->unPrivate.stListMenu.s32Top)* s32WndWidth) / UI_COORD_MAX;

		pstListMenu->pstMenuList[s32Num].y = ((pstAttr->u32WndY  +
								pstWnd->unPrivate.stListMenu.s32Left) * s32WndHeight) / UI_COORD_MAX;

		pstListMenu->pstMenuList[s32Num].w = ((pstAttr->u32WndHeight -
								pstWnd->unPrivate.stListMenu.s32Right -
								pstWnd->unPrivate.stListMenu.s32Left) * s32WndWidth) / UI_COORD_MAX;

		pstListMenu->pstMenuList[s32Num].h = ((pstAttr->u32WndHeight -
								pstWnd->unPrivate.stListMenu.s32Bottom -
								pstWnd->unPrivate.stListMenu.s32Top) * s32WndHeight) / UI_COORD_MAX;
#endif
#endif
		pstListMenu->pstMenuList[s32Num].id = pstAttr->u32Id;
		pstListMenu->pstMenuList[s32Num].caption = pstAttr->s8Name;
		pstListMenu->pstMenuList[s32Num].dwAddData = (DWORD)&pstWnd->pstWidget[s32Num];

		if(pstListMenu->pstMenuList[s32Num].h > s32ChildCtrlHight) {
			s32ChildCtrlHight = pstListMenu->pstMenuList[s32Num].h;
		}
	}


	pstAttr = &pstWnd->stCommon.stAttr;
	pstFops = &pstWnd->stCommon.stFops;



	u32WndId = WND_WIDGET_CreateListMenu2(pstAttr->u64Style,
								pstAttr->u32Id,
								s32WinX,
								s32WndY,
								s32WndWidth,
								s32WndHeight,
								pstAttr->u32ParentWndId,
								pstListMenu->pstMenuList, pstListMenu->s32MenuListNum,
								s32ChildCtrlHight,
								(DWORD)pstWnd,
								pstFops->CallBack,pstListMenu->s32ChildArray);



	for(s32Num = 0; s32Num < pstListMenu->s32MenuListNum; s32Num++) {
		pstAttr = &pstWnd->pstWidget[s32Num].stCommon.stAttr;
		pstAttr->u32WndId = MINI_INTF_ScrollCtrlGetWndId(u32WndId, pstAttr->u32Id);
		WND_WIDGET_EnbleStly(&pstWnd->pstWidget[s32Num]);

		SetWindowAdditionalData(pstAttr->u32WndId, (DWORD)&pstWnd->pstWidget[s32Num]);

		if(pstWnd->pstWidget[s32Num].stCommon.stFops.CallBack) {
			QLOG(TDBG, "设置回调函数\n");
			/*设置回调函数*/
			SetNotificationCallback (pstAttr->u32WndId, pstWnd->pstWidget[s32Num].stCommon.stFops.CallBackByVoid);
		}

	}





	//u32WndId = pstWnd->stCommon.stAttr.u32WndId;

	return u32WndId;
/*
WND_CREATE_ListMenuErr:

	if(pstListMenu->pstMenuList) {
		free(pstListMenu->pstMenuList);
	}
	if(pstListMenu->pstFont) {
		DestroyLogFont (pstListMenu->pstFont);
	}

	return -1;
*/

}

unsigned int WND_CREATE_ListMenuDestroy(WND_WIDGET_S *pstWnd)
{
	WND_WIDGET_LIST_MENU_S *pstListMenu = &pstWnd->unPrivate.stListMenu;
	//int s32Num;

#if 0
	for(s32Num = 0; s32Num < pstListMenu->s32MenuListNum; s32Num++) {
		if((char *)pstListMenu->pstMenuList[s32Num].class_name) {
			//free((char *)pstListMenu->pstMenuList[s32Num].class_name);
			pstListMenu->pstMenuList[s32Num].class_name = NULL;
		}
		if((char *)pstListMenu->pstMenuList[s32Num].caption) {
			//free((char *)pstListMenu->pstMenuList[s32Num].caption);
			pstListMenu->pstMenuList[s32Num].caption = NULL;
		}
	}
#endif

	if(pstListMenu->pstMenuList) {
		free(pstListMenu->pstMenuList);
		pstListMenu->pstMenuList = NULL;
	}

	pstListMenu->s32MenuListNum = 0;

	return 0;
}











unsigned int WND_CREATE_AttrPage(WND_WIDGET_S *pstWnd, unsigned int u32WndX, unsigned int u32WndY, unsigned int u32WndWidth, unsigned int u32WndHeight)
{
#if 0
	WND_WIDGET_ATTR_PAGE_S *pstAttrPageHandle = NULL;//&pstWnd->unPrivate.stAttrPage;

	WND_ATTR_S *pstAttr = NULL;
	WND_FOPS_S *pstFops = NULL;
	int s32AttrPageInfoNum, s32CtrlNum;
	CTRLDATA *pstControls = NULL;
	WND_WIDGET_S *pstTempWnd = NULL;

	pstAttr = &pstWnd->stCommon.stAttr;
	pstFops = &pstWnd->stCommon.stFops;
	char s8ClassName[64];

	pstWnd->stCommon.stAttr.u32WndId = MINI_INTF_CreateWndPropSheet(pstAttr->u64Style,
										pstAttr->u32Id,
										u32WndX,
										u32WndY,
										u32WndWidth,
										u32WndHeight,
										pstAttr->u32ParentWndId,
										(DWORD)pstWnd,
										pstFops->CallBackByVoid);


	if(pstWnd->s32WidgetNum <= 0 || pstWnd->pstWidget == NULL) {
		QLOG(ERR, "属性页子控件数量出错 [%d]\n", pstWnd->s32WidgetNum);
		return 0;
	}

	/*需要创建多少个属性页*/



	/*需要创建多少个属性页的页面*/
	for(s32AttrPageInfoNum = 0; s32AttrPageInfoNum < pstWnd->s32WidgetNum; s32AttrPageInfoNum++) {
	//for(s32AttrPageInfoNum = 0; s32AttrPageInfoNum < 1; s32AttrPageInfoNum++) {

		pstAttr = &pstWnd->pstWidget[s32AttrPageInfoNum].stCommon.stAttr;
		pstFops = &pstWnd->pstWidget[s32AttrPageInfoNum].stCommon.stFops;
		pstAttrPageHandle = &pstWnd->pstWidget[s32AttrPageInfoNum].unPrivate.stAttrPage;

		memset(&pstAttrPageHandle->stAttrPage, 0, sizeof(DLGTEMPLATE));

		pstAttrPageHandle->stAttrPage.dwStyle = pstAttr->u64Style;
		pstAttrPageHandle->stAttrPage.dwExStyle = pstAttr->u64ExStyle;

		/* 坐标实际不起效果*/
		pstAttrPageHandle->stAttrPage.x = u32WndX;
		pstAttrPageHandle->stAttrPage.y = u32WndY;
		pstAttrPageHandle->stAttrPage.w = u32WndWidth;
		pstAttrPageHandle->stAttrPage.h = u32WndHeight;

		pstAttrPageHandle->stAttrPage.caption = (char*)malloc(sizeof(pstAttr->s8Name));
		memset((char*)pstAttrPageHandle->stAttrPage.caption, 0, sizeof(pstAttr->s8Name));
		snprintf((char*)pstAttrPageHandle->stAttrPage.caption, sizeof(pstAttr->s8Name), pstAttr->s8Name);
		pstAttrPageHandle->stAttrPage.hIcon = 0;
		pstAttrPageHandle->stAttrPage.hMenu = 0;
		pstAttrPageHandle->stAttrPage.dwAddData = 0;//&pstWnd->pstWidget[s32AttrPageInfoNum];
		pstAttrPageHandle->stAttrPage.controlnr = 0;


		if(pstWnd->pstWidget[s32AttrPageInfoNum].pstWidget && pstWnd->pstWidget[s32AttrPageInfoNum].s32WidgetNum > 0) {

			pstAttrPageHandle->stAttrPage.controlnr = pstWnd->pstWidget[s32AttrPageInfoNum].s32WidgetNum;
			pstAttrPageHandle->stAttrPage.controls = malloc(sizeof(CTRLDATA)*pstWnd->pstWidget[s32AttrPageInfoNum].s32WidgetNum);
			memset(pstAttrPageHandle->stAttrPage.controls, 0, sizeof(CTRLDATA)*pstWnd->pstWidget[s32AttrPageInfoNum].s32WidgetNum);

			pstControls = pstAttrPageHandle->stAttrPage.controls;

			/*属性页的页面里面需要创建多少个控件*/
			for(s32CtrlNum = 0; s32CtrlNum < pstWnd->pstWidget[s32AttrPageInfoNum].s32WidgetNum; s32CtrlNum++) {

				/* 如果有控件*/
				pstTempWnd = &pstWnd->pstWidget[s32AttrPageInfoNum].pstWidget[s32CtrlNum];
				snprintf(s8ClassName, sizeof(s8ClassName), "%s", MINIGUI_GET_CtrlClassName(pstTempWnd->enType));
				pstControls[s32CtrlNum].class_name = (char*)malloc(strlen(s8ClassName) +1);
				snprintf((char*)pstControls[s32CtrlNum].class_name, strlen(s8ClassName) +1, s8ClassName);
				pstControls[s32CtrlNum].dwStyle = pstTempWnd->stCommon.stAttr.u64Style;
				pstControls[s32CtrlNum].dwExStyle = pstTempWnd->stCommon.stAttr.u64ExStyle;

				pstControls[s32CtrlNum].x = (pstTempWnd->stCommon.stAttr.u32WndX*u32WndWidth)/UI_COORD_MAX;
				pstControls[s32CtrlNum].y = (pstTempWnd->stCommon.stAttr.u32WndY*u32WndHeight)/UI_COORD_MAX;
				pstControls[s32CtrlNum].w = (pstTempWnd->stCommon.stAttr.u32WndWidth*u32WndWidth)/UI_COORD_MAX;
				pstControls[s32CtrlNum].h = (pstTempWnd->stCommon.stAttr.u32WndHeight*u32WndHeight)/UI_COORD_MAX;
				pstControls[s32CtrlNum].id = pstTempWnd->stCommon.stAttr.u32Id;
				pstControls[s32CtrlNum].dwAddData = 0;
				pstControls[s32CtrlNum].caption = (char*)malloc(sizeof(pstTempWnd->stCommon.stAttr.s8Name));
				memset((char*)pstControls[s32CtrlNum].caption, 0, sizeof(pstTempWnd->stCommon.stAttr.s8Name));
				snprintf((char*)pstControls[s32CtrlNum].caption, sizeof(pstTempWnd->stCommon.stAttr.s8Name), pstTempWnd->stCommon.stAttr.s8Name);

			}
		}

		pstAttrPageHandle->s32Index = MINI_INTF_PSM_AddPage(pstWnd->stCommon.stAttr.u32WndId,
									&pstAttrPageHandle->stAttrPage,
									pstWnd->pstWidget[s32AttrPageInfoNum].stCommon.stFops.CallBack);

		if(pstWnd->pstWidget[s32AttrPageInfoNum].pstWidget && pstWnd->pstWidget[s32AttrPageInfoNum].s32WidgetNum > 0) {
			for(s32CtrlNum = 0; s32CtrlNum < pstWnd->pstWidget[s32AttrPageInfoNum].s32WidgetNum; s32CtrlNum++) {
				pstTempWnd = &pstWnd->pstWidget[s32AttrPageInfoNum].pstWidget[s32CtrlNum];

				pstTempWnd->stCommon.stAttr.u32ParentWndId = pstWnd->stCommon.stAttr.u32WndId;
				pstTempWnd->stCommon.stAttr.u32WndId = MINI_INTF_PSM_GetPageCtrlWndId(pstWnd->stCommon.stAttr.u32WndId,
							pstAttrPageHandle->s32Index, pstTempWnd->stCommon.stAttr.u32Id);

				if(pstTempWnd->stCommon.stFops.CallBack) {
					QLOG(TDBG, "设置[%s]回调函数\n", pstTempWnd->stCommon.stAttr.s8Name);
					/*设置回调函数*/
					SetNotificationCallback (pstTempWnd->stCommon.stAttr.u32WndId, pstTempWnd->stCommon.stFops.CallBackByVoid);
				}
				SetWindowBkColor(MINI_INTF_PSM_GetPageWndIdByIndex(pstWnd->stCommon.stAttr.u32WndId, pstAttrPageHandle->s32Index),
											//pstTempWnd->stCommon.stAttr.u32WndId,
											COLOR_black);

				if(pstTempWnd->enType == WND_WIDGET_TYPE_MENU_BUTTON_E) {
					int s32ItmNum;
					for(s32ItmNum = 0; s32ItmNum < pstTempWnd->unWidget.stAttrPage.s32ItmNum; s32ItmNum++) {
						MENUBUTTONITEM mbi; 		// 声明一个菜单条目结构体变量
						//mbi.text= pstTempWnd->unWidget.stAttrPage.ps8ItmName[s32ItmNum]; 			// 设置条目文字
						mbi.text= pstTempWnd->unWidget.stAttrPage.pstItm[s32ItmNum].ps8ItmName; 			// 设置条目文字
						mbi.bmp = NULL; 			// 在这里可以指定位图对象
						mbi.data = 0;
						SendMessage(pstTempWnd->stCommon.stAttr.u32WndId, MBM_ADDITEM, 0, (LPARAM)&mbi);
					}

				}
			}
		}

	}

	return pstWnd->stCommon.stAttr.u32WndId;
#else
	WND_WIDGET_ATTR_PAGE_S *pstAttrPageHandle = NULL;//&pstWnd->unWidget.stAttrPage;

	WND_ATTR_S *pstAttr = NULL;
	WND_FOPS_S *pstFops = NULL;
	int s32AttrPageInfoNum, s32CtrlNum;
	//CTRLDATA *pstControls = NULL;
	WND_WIDGET_S *pstPageCtrlWnd = NULL;
	WND_WIDGET_S *pstPageWnd = NULL;
	//WND_WIDGET_S *pstPageParentWnd = NULL;
	unsigned int u32Wnd;
	pstAttr = &pstWnd->stCommon.stAttr;
	pstFops = &pstWnd->stCommon.stFops;
	//char s8ClassName[64];

	u32Wnd = pstWnd->stCommon.stAttr.u32WndId = MINI_INTF_CreateWndPropSheet(pstAttr->u64Style,
										pstAttr->u32Id,
										u32WndX,
										u32WndY,
										u32WndWidth,
										u32WndHeight,
										pstAttr->u32ParentWndId,
										(DWORD)pstWnd,
										pstFops->CallBackByVoid);
	WND_WIDGET_EnbleStly(pstWnd);

	for(s32AttrPageInfoNum = 0; s32AttrPageInfoNum < pstWnd->s32WidgetNum; s32AttrPageInfoNum++) {
		pstAttrPageHandle = &pstWnd->pstWidget[s32AttrPageInfoNum].unPrivate.stAttrPage;



		pstPageWnd = &pstWnd->pstWidget[s32AttrPageInfoNum];


		pstAttr = &pstWnd->pstWidget[s32AttrPageInfoNum].stCommon.stAttr;
		pstFops = &pstWnd->pstWidget[s32AttrPageInfoNum].stCommon.stFops;
		pstAttrPageHandle = &pstWnd->pstWidget[s32AttrPageInfoNum].unPrivate.stAttrPage;

		memset(&pstAttrPageHandle->stAttrPage, 0, sizeof(DLGTEMPLATE));

		pstAttrPageHandle->stAttrPage.dwStyle = pstAttr->u64Style;
		pstAttrPageHandle->stAttrPage.dwExStyle = pstAttr->u64ExStyle;

		/* 坐标实际不起效果*/
		pstAttrPageHandle->stAttrPage.x = u32WndX;
		pstAttrPageHandle->stAttrPage.y = u32WndY;
		//pstAttrPageHandle->stAttrPage.w = u32WndWidth;
		//pstAttrPageHandle->stAttrPage.h = u32WndHeight;
		pstAttrPageHandle->stAttrPage.w = 100;
		pstAttrPageHandle->stAttrPage.h = 100;
		pstAttrPageHandle->stAttrPage.caption = pstAttr->s8Name;

		pstAttrPageHandle->stAttrPage.hIcon = 0;
		pstAttrPageHandle->stAttrPage.hMenu = 0;
		pstAttrPageHandle->stAttrPage.dwAddData = (DWORD)pstPageWnd;//&pstWnd->pstWidget[s32AttrPageInfoNum];
		pstAttrPageHandle->stAttrPage.controlnr = 0;

		/*添加属性页，返回的是属性页的条目*/
		pstAttrPageHandle->s32Index = MINI_INTF_PSM_AddPage(pstWnd->stCommon.stAttr.u32WndId,
											&pstAttrPageHandle->stAttrPage,
											pstWnd->pstWidget[s32AttrPageInfoNum].stCommon.stFops.CallBack);




		/*通过属性页的条目获取属性页窗口id*/
		pstPageWnd->stCommon.stAttr.u32WndId = MINI_INTF_PSM_GetPageWndIdByIndex(pstWnd->stCommon.stAttr.u32WndId,
																	pstAttrPageHandle->s32Index);
		pstPageWnd->stCommon.stSta.bCreate = true;
		SetWindowAdditionalData(pstPageWnd->stCommon.stAttr.u32WndId, (DWORD)pstPageWnd);

		/* 设置属性页的风格*/
		WND_WIDGET_EnbleStly(pstPageWnd);


		/*添加属性页部件*/
		if(pstPageWnd->pstWidget && pstPageWnd->s32WidgetNum > 0) {
			for(s32CtrlNum = 0; s32CtrlNum < pstWnd->pstWidget[s32AttrPageInfoNum].s32WidgetNum; s32CtrlNum++) {
				pstPageCtrlWnd = &pstWnd->pstWidget[s32AttrPageInfoNum].pstWidget[s32CtrlNum];
				WND_WIDGET_CreateSwitch(pstPageCtrlWnd,
									pstPageWnd->stCommon.stAttr.u32WndId,
									(pstPageCtrlWnd->stCommon.stAttr.u32WndX*u32WndWidth)/UI_COORD_MAX,
									(pstPageCtrlWnd->stCommon.stAttr.u32WndY*u32WndHeight)/UI_COORD_MAX,
									(pstPageCtrlWnd->stCommon.stAttr.u32WndWidth*u32WndWidth)/UI_COORD_MAX,
									(pstPageCtrlWnd->stCommon.stAttr.u32WndHeight*u32WndHeight)/UI_COORD_MAX);

#if 0
				/* 在属性页上面创建控件*/
				pstPageCtrlWnd->stCommon.stAttr.u32WndId = MINI_INTF_CreateWnd(MINIGUI_GET_CtrlClassName(pstPageCtrlWnd->enType),
									pstPageCtrlWnd->stCommon.stAttr.s8Name,
									pstPageCtrlWnd->stCommon.stAttr.u64Style,
									pstPageCtrlWnd->stCommon.stAttr.u32Id,
									(pstPageCtrlWnd->stCommon.stAttr.u32WndX*u32WndWidth)/UI_COORD_MAX,
									(pstPageCtrlWnd->stCommon.stAttr.u32WndY*u32WndHeight)/UI_COORD_MAX,
									(pstPageCtrlWnd->stCommon.stAttr.u32WndWidth*u32WndWidth)/UI_COORD_MAX,
									(pstPageCtrlWnd->stCommon.stAttr.u32WndHeight*u32WndHeight)/UI_COORD_MAX,
									pstPageWnd->stCommon.stAttr.u32WndId,
									(DWORD)pstPageCtrlWnd,
									pstPageCtrlWnd->stCommon.stFops.CallBackByVoid);

				//SetWindowAdditionalData(pstPageCtrlWnd->stCommon.stAttr.u32WndId, pstPageCtrlWnd);



				/* 设置属性页上面子控件的颜色*/
				if(pstPageCtrlWnd->stCommon.stAttr.enBkColor == UI_COLOR_PARENT_E) {
					/* 这里这样写是因为属性页上面的子控件不知道为什么传不进去私有数据,
						这里就判断下如果是跟随父窗口背景风格就直接设置*/
					//SetWindowBkColor(pstPageCtrlWnd->stCommon.stAttr.u32WndId,
					//				WND_WIDGET_GetMiniguiColour(WND_WIDGET_GetBkColour(pstWnd)));
					SetWindowBkColor(pstPageCtrlWnd->stCommon.stAttr.u32WndId,
									WND_WIDGET_GetMiniguiColour(WND_WIDGET_GetBkColour(pstPageWnd)));
				} else {
					WND_WIDGET_EnbleBkColour(pstPageCtrlWnd);
				}
				WND_WIDGET_SetFontcolor(pstPageCtrlWnd,WND_WIDGET_GetFontColour(pstPageCtrlWnd));

				//WND_WIDGET_EnbleStly(&pstWnd->pstWidget[s32Num]);
				WND_WIDGET_EnbleFontSize(pstPageCtrlWnd);

#if 0
				/* 设置字体颜色*/

				HDC hdc = GetDC(pstPageCtrlWnd->stCommon.stAttr.u32WndId);
				QLOG(TDBG, "设置颜色\n");
				SetWindowElementAttr(pstPageCtrlWnd->stCommon.stAttr.u32WndId, WE_FGC_WINDOW, Pixel2DWORD(hdc, RGB2Pixel(hdc, 0xff, 0x00, 0x00)));
				SetTextColor(hdc, COLOR_darkyellow);

				ReleaseDC (hdc);
#endif
				/* 一些特别的控件可能需要添加一些条目*/
				if(pstPageCtrlWnd->enType == WND_WIDGET_TYPE_MENU_BUTTON_E) {
					int s32ItmNum;
					for(s32ItmNum = 0; s32ItmNum < pstPageCtrlWnd->unPrivate.stAttrPage.s32ItmNum; s32ItmNum++) {
						MENUBUTTONITEM mbi; 		// 声明一个菜单条目结构体变量
						mbi.text= pstPageCtrlWnd->unPrivate.stAttrPage.pstItm[s32ItmNum].ps8ItmName; 			// 设置条目文字
						mbi.bmp = NULL; 			// 在这里可以指定位图对象
						mbi.data = 0;
						SendMessage(pstPageCtrlWnd->stCommon.stAttr.u32WndId, MBM_ADDITEM, 0, (LPARAM)&mbi);
					}
				}
#endif
			}
		}

	}



#endif

	//return pstWnd->stCommon.stAttr.u32WndId;
	return u32Wnd;
}



int WND_CREATE_AttrPageDestroy(WND_WIDGET_S *pstWnd)
{
#if 0
	WND_WIDGET_ATTR_PAGE_S *pstAttrPageHandle = NULL;//&pstWnd->unPrivate.stAttrPage;


	int s32AttrPageInfoNum, s32CtrlNum;
	CTRLDATA *pstControls = NULL;


	for(s32AttrPageInfoNum = 0; s32AttrPageInfoNum < pstWnd->s32WidgetNum; s32AttrPageInfoNum++) {
		pstAttrPageHandle = &pstWnd->pstWidget[s32AttrPageInfoNum].unPrivate.stAttrPage;
		if(pstWnd->pstWidget[s32AttrPageInfoNum].pstWidget && pstWnd->pstWidget[s32AttrPageInfoNum].s32WidgetNum > 0) {
			pstAttrPageHandle->stAttrPage.controlnr = pstWnd->pstWidget[s32AttrPageInfoNum].s32WidgetNum;
			pstControls = pstAttrPageHandle->stAttrPage.controls;
			/*属性页的页面里面需要创建多少个控件*/
			for(s32CtrlNum = 0; s32CtrlNum < pstWnd->pstWidget[s32AttrPageInfoNum].s32WidgetNum; s32CtrlNum++) {
				if(pstControls[s32CtrlNum].class_name) {
					free((char*)pstControls[s32CtrlNum].class_name);
					pstControls[s32CtrlNum].class_name = NULL;
				}
				if(pstControls[s32CtrlNum].caption) {
					free((char*)pstControls[s32CtrlNum].caption);
					pstControls[s32CtrlNum].caption = NULL;
				}
			}
			if(pstAttrPageHandle->stAttrPage.controls) {
				free(pstAttrPageHandle->stAttrPage.controls);
				pstAttrPageHandle->stAttrPage.controls = NULL;
			}
		}
		if(pstAttrPageHandle->stAttrPage.caption) {
			free((char*)pstAttrPageHandle->stAttrPage.caption);
			pstAttrPageHandle->stAttrPage.caption = NULL;
		}
	}
#else
/*
	int s32AttrPageInfoNum, s32CtrlNum;
	for(s32AttrPageInfoNum = 0; s32AttrPageInfoNum < pstWnd->s32WidgetNum; s32AttrPageInfoNum++) {
		if(pstWnd->pstWidget[s32AttrPageInfoNum].pstWidget && pstWnd->pstWidget[s32AttrPageInfoNum].s32WidgetNum > 0) {
			for(s32CtrlNum = 0; s32CtrlNum < pstWnd->pstWidget[s32AttrPageInfoNum].s32WidgetNum; s32CtrlNum++) {
				//MINI_INTF_DestroyWnd(pstWnd->pstWidget[s32AttrPageInfoNum].pstWidget[s32CtrlNum].stCommon.stAttr.u32WndId);
			}
		}
		//MINI_INTF_DestroyWnd(pstWnd->pstWidget[s32AttrPageInfoNum].stCommon.stAttr.u32WndId);
	}
*/
#endif
	return 0;
}



unsigned int WND_WIDGET_CreateDlg(WND_WIDGET_S *pstWnd,
									unsigned int u32WndX,
									unsigned int u32WndY,
									unsigned int u32WndWidth,
									unsigned int u32WndHeight)
{
	//int s32Num;
	DLGTEMPLATE *pstDlg = &pstWnd->unPrivate.stDlg.stDlgInfo;
	//WND_WIDGET_DLG_S *pstDlgInfo = &pstWnd->unWidget.stDlg;
	//WND_WIDGET_S *pstChildCtrl = NULL;


	pstDlg->dwStyle = pstWnd->stCommon.stAttr.u64Style;
	pstDlg->dwExStyle = pstWnd->stCommon.stAttr.u64ExStyle;
	pstDlg->x = u32WndX;
	pstDlg->y = u32WndY;
	pstDlg->w = u32WndWidth;
	pstDlg->h = u32WndHeight;
	pstDlg->caption = pstWnd->stCommon.stAttr.s8Name;
	pstDlg->dwAddData = (DWORD)pstWnd;

	pstDlg->controlnr = 0;
#if 0
	pstDlg->controlnr = pstWnd->s32WidgetNum;

	/* 填充子控件*/
	if(pstWnd->pstWidget && pstWnd->s32WidgetNum > 0) {
		pstDlg->controls = (CTRLDATA*)malloc(sizeof(CTRLDATA) * pstWnd->s32WidgetNum);
		memset(pstDlg->controls, 0, sizeof(CTRLDATA) * pstWnd->s32WidgetNum);

		for(s32Num = 0; s32Num < pstWnd->s32WidgetNum; s32Num++) {
			pstChildCtrl = &pstWnd->pstWidget[s32Num];

			/* 转换风格*/
			WND_WIDGET_StlySwitch(pstChildCtrl, 0);

			/*填充子控件数据*/
			pstDlg->controls[s32Num].class_name = MINIGUI_GET_CtrlClassName(pstChildCtrl->enType);
			pstDlg->controls[s32Num].dwStyle = pstChildCtrl->stCommon.stAttr.u64Style;
			pstDlg->controls[s32Num].dwExStyle = pstChildCtrl->stCommon.stAttr.u64ExStyle;
			pstDlg->controls[s32Num].x = (pstChildCtrl->stCommon.stAttr.u32WndX * u32WndWidth)/UI_COORD_MAX;
			pstDlg->controls[s32Num].y = (pstChildCtrl->stCommon.stAttr.u32WndY * u32WndHeight)/UI_COORD_MAX;
			pstDlg->controls[s32Num].w = (pstChildCtrl->stCommon.stAttr.u32WndWidth * u32WndWidth)/UI_COORD_MAX;
			pstDlg->controls[s32Num].h = (pstChildCtrl->stCommon.stAttr.u32WndHeight * u32WndHeight)/UI_COORD_MAX;
			pstDlg->controls[s32Num].id = pstChildCtrl->stCommon.stAttr.u32Id;
			pstDlg->controls[s32Num].caption = pstChildCtrl->stCommon.stAttr.s8Name;

		}
	}
#endif
	/*对话框在这里会阻塞，返回的时候代表对话框已经结束*/
	DialogBoxIndirectParam(pstDlg , pstWnd->stCommon.stAttr.u32ParentWndId , pstWnd->stCommon.stFops.CallBack , 0L);


	return 0;

}

void WND_WIDGET_DestroyDlg(WND_WIDGET_S *pstWnd)
{
#if 0
	int s32Num;
	for(s32Num = 0; s32Num < pstWnd->s32WidgetNum; s32Num++) {
		pstChildCtrl = &pstWnd->pstWidget[s32Num];

		/* 转换风格*/
		WND_WIDGET_StlySwitch(pstChildCtrl, 0);

		/*填充子控件数据*/
		pstDlg->controls[s32Num].class_name = MINIGUI_GET_CtrlClassName(pstChildCtrl->enType);
		pstDlg->controls[s32Num].dwStyle = pstChildCtrl->stCommon.stAttr.u64Style;
		pstDlg->controls[s32Num].dwExStyle = pstChildCtrl->stCommon.stAttr.u64ExStyle;
		pstDlg->controls[s32Num].x = (pstChildCtrl->stCommon.stAttr.u32WndX * u32WndWidth)/UI_COORD_MAX;
		pstDlg->controls[s32Num].y = (pstChildCtrl->stCommon.stAttr.u32WndY * u32WndHeight)/UI_COORD_MAX;
		pstDlg->controls[s32Num].w = (pstChildCtrl->stCommon.stAttr.u32WndWidth * u32WndWidth)/UI_COORD_MAX;
		pstDlg->controls[s32Num].h = (pstChildCtrl->stCommon.stAttr.u32WndHeight * u32WndHeight)/UI_COORD_MAX;
		pstDlg->controls[s32Num].id = pstChildCtrl->stCommon.stAttr.u32Id;
		pstDlg->controls[s32Num].caption = pstChildCtrl->stCommon.stAttr.s8Name;

	}
#endif
}



unsigned int WND_WIDGET_CreateIconView(WND_WIDGET_S *pstWnd,
									unsigned int u32WndX,
									unsigned int u32WndY,
									unsigned int u32WndWidth,
									unsigned int u32WndHeight)
{


	HWND u32WndMenu;
	RECT stMargin;

	//pstWnd->stCommon.stAttr.u64Style |= WS_BORDER | WS_THICKFRAME | WS_EX_BROUNDCNS;

	//pstWnd->stCommon.stAttr.u64Style |= IVS_AUTOSORT | IVS_LOOP;

	/* 创建图标控件*/
	u32WndMenu = MINI_INTF_CreateMenuWndByIcon(pstWnd->stCommon.stAttr.u64Style,
											pstWnd->stCommon.stAttr.u32Id,
											u32WndX,
											u32WndY,
											u32WndWidth,
											u32WndHeight,
											pstWnd->stCommon.stAttr.u32ParentWndId,
											(DWORD)pstWnd,
											pstWnd->stCommon.stFops.CallBackByVoid);





	/* 设置图标控件的大小*/


	SendMessage(u32WndMenu, IVM_SETITEMSIZE, u32WndWidth, u32WndHeight);
	QLOG(TDBG, "u32WndWidth[%u] u32WndHeight[%u]\n", u32WndWidth, u32WndHeight);

	memset(&stMargin, 0, sizeof(stMargin));
	/* 设置图标控件的边缘值 为0*/



	stMargin.left = 0;
    stMargin.top = 0;
    stMargin.right = 0;
    stMargin.bottom = 0;
	SendMessage(u32WndMenu, IVM_SETMARGINS, 0, (LPARAM)&stMargin);

	memset(&pstWnd->unPrivate.stIconView.stIconMenu, 0, sizeof(BITMAP));
	memset(&pstWnd->unPrivate.stIconView.stIconMenuCursel, 0, sizeof(BITMAP));

	LoadBitmap(HDC_SCREEN, &pstWnd->unPrivate.stIconView.stIconMenu, pstWnd->unPrivate.stIconView.s8IconPath);
	LoadBitmap(HDC_SCREEN, &pstWnd->unPrivate.stIconView.stIconMenuCursel, pstWnd->unPrivate.stIconView.s8IconPathCursel);


	memset(&pstWnd->unPrivate.stIconView.stIconItem, 0, sizeof(IVITEMINFO));

	pstWnd->unPrivate.stIconView.stIconItem.bmp = &pstWnd->unPrivate.stIconView.stIconMenu;
	pstWnd->unPrivate.stIconView.stIconItem.nItem = 0;//s32Itm;
	if(pstWnd->unPrivate.stIconView.s8Name == NULL || strlen(pstWnd->unPrivate.stIconView.s8Name) <= 0) {
		/* 图标的汉字名称，填NULL会消失，不填NULL只填数组虽然不会显示汉字但还是会占空间*/
		pstWnd->unPrivate.stIconView.stIconItem.label = NULL;
	} else {

		pstWnd->unPrivate.stIconView.stIconItem.label = pstWnd->unPrivate.stIconView.s8Name;
	}
	pstWnd->unPrivate.stIconView.stIconItem.addData = 0;//u64AddData;

	/* 添加按钮图标*/
	SendMessage (u32WndMenu, IVM_ADDITEM, 0, (LPARAM)&pstWnd->unPrivate.stIconView.stIconItem);



	return u32WndMenu;
}

void WND_WIDGET_DestroyIconView(WND_WIDGET_S *pstWnd)
{
	MINI_INTF_DelOneIconMenu(&pstWnd->unPrivate.stIconView.stIconMenu);
}


/*!
 * 刷新同一组下面的图标按钮的当前高亮选项
 * @param pstParentWnd 同一组图标控件的父窗口句柄
 * @param u32Wnd 当前需要被点亮图标控件的图标控件的窗口id
 * @see
 */
int WND_WIDGET_FlushIconCursel(WND_WIDGET_S *pstParentWnd, unsigned int u32Wnd)
{

	int s32Index;
	int s32Num;
	if(pstParentWnd == NULL) {
		QLOG(ERR, "父窗口句柄为空\n");
		return -1;
	}
	if(pstParentWnd->pstWidget == NULL) {
		QLOG(ERR, "子窗口句柄为空\n");
		return -1;
	}
#if 1
	for(s32Num = 0; s32Num < pstParentWnd->s32WidgetNum; s32Num++) {
		s32Index = SendMessage (pstParentWnd->pstWidget[s32Num].stCommon.stAttr.u32WndId, SVM_GETCURSEL, 0, 0);
		if(pstParentWnd->pstWidget[s32Num].unPrivate.stIconView.bCursel == true &&
					pstParentWnd->pstWidget[s32Num].stCommon.stAttr.u32WndId != u32Wnd) {

			/* 删除图标*/
			SendMessage (pstParentWnd->pstWidget[s32Num].stCommon.stAttr.u32WndId, IVM_RESETCONTENT, 0, 0);

			/* 添加图标*/
			MINI_INTF_AddIconToMenu(pstParentWnd->pstWidget[s32Num].stCommon.stAttr.u32WndId,
							0,
							&pstParentWnd->pstWidget[s32Num].unPrivate.stIconView.stIconMenu,
							pstParentWnd->pstWidget[s32Num].unPrivate.stIconView.s8Name,
							&pstParentWnd->unPrivate.stIconView.stIconItem,
							(DWORD)&pstParentWnd->pstWidget[s32Num]);
			pstParentWnd->pstWidget[s32Num].unPrivate.stIconView.bCursel = false;
			//WND_WIDGET_SetFontcolor(pstParentWnd->pstWidget[s32Num].stCommon.stAttr.u32WndId,
			//					WND_WIDGET_GetFontColour(&pstParentWnd->pstWidget[s32Num]));
			WND_WIDGET_SetFontcolor(&pstParentWnd->pstWidget[s32Num],
								WND_WIDGET_GetFontColour(&pstParentWnd->pstWidget[s32Num]));


		} else if(s32Index == 0 && pstParentWnd->pstWidget[s32Num].stCommon.stAttr.u32WndId == u32Wnd) {
			//WND_WIDGET_SetFontcolor(pstParentWnd->pstWidget[s32Num].stCommon.stAttr.u32WndId,
			//					pstParentWnd->pstWidget[s32Num].unWidget.stIconView.enFontColorCursel);

			WND_WIDGET_SetFontcolor(&pstParentWnd->pstWidget[s32Num],
									pstParentWnd->pstWidget[s32Num].unPrivate.stIconView.enFontColorCursel);

			/* 删除图标*/
			SendMessage (pstParentWnd->pstWidget[s32Num].stCommon.stAttr.u32WndId, IVM_RESETCONTENT, 0, 0);

			/* 添加图标*/
			MINI_INTF_AddIconToMenu(pstParentWnd->pstWidget[s32Num].stCommon.stAttr.u32WndId,
							0,
							&pstParentWnd->pstWidget[s32Num].unPrivate.stIconView.stIconMenuCursel,
							pstParentWnd->pstWidget[s32Num].unPrivate.stIconView.s8Name,
							&pstParentWnd->unPrivate.stIconView.stIconItem,
							(DWORD)&pstParentWnd->pstWidget[s32Num]);
			pstParentWnd->pstWidget[s32Num].unPrivate.stIconView.bCursel = true;
		}

	}
#endif
	return 0;
}

/*!
 * 刷新一个窗口的同一个组窗口的选中高亮
 * @return 0.成功 -1.失败
 * @param u32Wnd 要刷新的窗口
 * @see
 */
int WND_WIDGET_FlushIconCtrlSetsCursel(unsigned int u32Wnd)
{
	WND_WIDGET_S *pstWnd = NULL;
	WND_WIDGET_S *pstParentWnd = NULL;

	pstWnd = (WND_WIDGET_S*)GetWindowAdditionalData(u32Wnd);
	pstParentWnd = (WND_WIDGET_S*)GetWindowAdditionalData(GetParent(u32Wnd));
	if(pstWnd == NULL) {
		SLOG(ERR, "获取窗口结构体失败\n");
		return -1;
	}

	if(pstParentWnd) {
		WND_WIDGET_FlushIconCursel(pstParentWnd, u32Wnd);
	}
	return 0;
}


unsigned int WND_WIDGET_CreateCtrlSets(WND_WIDGET_S *pstWnd,
									unsigned int u32WndX,
									unsigned int u32WndY,
									unsigned int u32WndWidth,
									unsigned int u32WndHeight)


{
	int s32Num;
	int s32CtrlWidth;
	int s32CtlrHeight;
	int s32Count;
	unsigned int u32WndStart = 0;
	unsigned int u32WndStartHeight = 0;

	unsigned int WndMenuList;
#if 0
	unsigned int u32ChildWndX;
	unsigned int u32ChildWndY;
	unsigned int u32ChildWndWidth;
	unsigned int u32ChildWndHeight;
#endif
#if 0
	if(pstWnd->pstWidget == NULL) {
		QLOG(ERR, "控件集合的子控件句柄为空\n");
		return -1;
	}

#endif
	if(pstWnd->unPrivate.stCtrlSets.bHScroll) {
		pstWnd->stCommon.stAttr.u64Style |= WS_HSCROLL;
	}
	if(pstWnd->unPrivate.stCtrlSets.bVScroll) {
		pstWnd->stCommon.stAttr.u64Style |= WS_VSCROLL;
	}

#if 1
	WndMenuList = CreateWindow(CTRL_SCROLLWND,
								"",
								pstWnd->stCommon.stAttr.u64Style,
								pstWnd->stCommon.stAttr.u32Id,
								u32WndX,
								u32WndY,
								u32WndWidth,
								u32WndHeight,
								pstWnd->stCommon.stAttr.u32ParentWndId,
								0);
	//QLOG(TDBG, " [%u] [%u] [%u] [%u] \n", u32WndX,u32WndY,u32WndWidth,u32WndHeight);
#else


	HDC hdc = GetDC(pstWnd->stCommon.stAttr.u32ParentWndId);



#if 1
	pstWnd->stCommon.stAttr.u64Style |= SS_NOTIFY;

	WndMenuList = CreateWindow(CTRL_STATIC,
								"",
								pstWnd->stCommon.stAttr.u64Style,
								pstWnd->stCommon.stAttr.u32Id,
								u32WndX,
								u32WndY,
								u32WndWidth,
								u32WndHeight,
								pstWnd->stCommon.stAttr.u32ParentWndId,
								0);




#else
	pstWnd->stCommon.stAttr.u64Style |= SS_BITMAP | SS_NOTIFY | SS_CENTERIMAGE;

	LoadBitmap(hdc, &pstWnd->unPrivate.stCtrlSets.stIconMenu, pstWnd->unPrivate.stCtrlSets.s8IconPath);

	pstWnd->stCommon.stAttr.u32WndId = WndMenuList = MINI_INTF_CreateWnd(CTRL_STATIC,
									pstWnd->stCommon.stAttr.s8Name,
									pstWnd->stCommon.stAttr.u64Style,
									pstWnd->stCommon.stAttr.u32Id,
									u32WndX, u32WndY, u32WndWidth, u32WndHeight,
									pstWnd->stCommon.stAttr.u32ParentWndId,
									(DWORD)&pstWnd->unPrivate.stCtrlSets.stIconMenu,
									pstWnd->stCommon.stFops.CallBackByVoid);

#endif

	ReleaseDC(hdc);


#endif

#if 1

	SetWindowAdditionalData(WndMenuList, (DWORD)pstWnd);
	if(pstWnd->unPrivate.stCtrlSets.s32Direction == 3) {
		/**
		 * @brief 以固定的高度创建列表，则要设置列表的高度
		 */
		MINI_INTF_ScrollCtrlSetCententSize(WndMenuList,
			0,
			((pstWnd->unPrivate.stCtrlSets.s32Height * u32WndHeight) / UI_COORD_MAX) * pstWnd->s32WidgetNum);
	} else {

		MINI_INTF_ScrollCtrlSetCententSize(WndMenuList, 0, 0);
	}
#endif
	if(pstWnd->stCommon.stFops.CallBack) {


		/* 设置回调函数*/
		//SendMessage (WndMenuList, SVM_SETCONTAINERPROC, 0, (LPARAM)pstWnd->stCommon.stFops.CallBackByVoid );
	}

	//WND_WIDGET_EnbleStly(pstWnd);

	u32WndStart = 0;

	for(s32Num = 0; s32Num < pstWnd->s32WidgetNum; s32Num++) {


		if(pstWnd->unPrivate.stCtrlSets.s32Direction == 0) {
			s32CtrlWidth = pstWnd->stCommon.stAttr.u32WndWidth / pstWnd->s32WidgetNum;
			//s32CtrlWidth = u32WndWidth / pstWnd->s32WidgetNum;


			pstWnd->pstWidget[s32Num].stCommon.stAttr.u32WndX = u32WndStart + pstWnd->unPrivate.stCtrlSets.s32Left;
			pstWnd->pstWidget[s32Num].stCommon.stAttr.u32WndY = 0 + pstWnd->unPrivate.stCtrlSets.s32Top;
			//pstWnd->pstWidget[s32Num].stCommon.stAttr.u32WndY = pstWnd->stCommon.stAttr.u32WndY + pstWnd->unPrivate.stCtrlSets.s32Top;

			pstWnd->pstWidget[s32Num].stCommon.stAttr.u32WndWidth = s32CtrlWidth -
														pstWnd->unPrivate.stCtrlSets.s32Left -
														pstWnd->unPrivate.stCtrlSets.s32Right;
			pstWnd->pstWidget[s32Num].stCommon.stAttr.u32WndHeight = pstWnd->stCommon.stAttr.u32WndHeight -
							pstWnd->unPrivate.stCtrlSets.s32Top -
							pstWnd->unPrivate.stCtrlSets.s32Bottom;
#if 0
			u32ChildWndX = ((u32WndStart + pstWnd->unPrivate.stCtrlSets.s32Left) * u32WndWidth) / UI_COORD_MAX;
			u32ChildWndY = ((0 + pstWnd->unPrivate.stCtrlSets.s32Top) * u32WndHeight) / UI_COORD_MAX;
			u32ChildWndWidth = ((s32CtrlWidth -
							pstWnd->unPrivate.stCtrlSets.s32Left -
							pstWnd->unPrivate.stCtrlSets.s32Right) * u32WndWidth) / UI_COORD_MAX;
			u32ChildWndHeight = u32WndHeight - ((pstWnd->unPrivate.stCtrlSets.s32Top +
							pstWnd->unPrivate.stCtrlSets.s32Bottom) * u32WndHeight)/ UI_COORD_MAX;

			QLOG(TDBG, "[%u] [%u] [%u] [%u]-------[%u] [%u] [%u] [%u] \n",
						pstWnd->pstWidget[s32Num].stCommon.stAttr.u32WndX,
						pstWnd->pstWidget[s32Num].stCommon.stAttr.u32WndY,
						pstWnd->pstWidget[s32Num].stCommon.stAttr.u32WndWidth,
						pstWnd->pstWidget[s32Num].stCommon.stAttr.u32WndHeight,
						u32ChildWndX,
						u32ChildWndY,
						u32ChildWndWidth,
						u32ChildWndHeight);
#endif
			u32WndStart +=s32CtrlWidth;
		} else if(pstWnd->unPrivate.stCtrlSets.s32Direction == 1) {
			s32CtlrHeight = (pstWnd->stCommon.stAttr.u32WndHeight / pstWnd->s32WidgetNum);

			pstWnd->pstWidget[s32Num].stCommon.stAttr.u32WndX = 0 + pstWnd->unPrivate.stCtrlSets.s32Left;
			pstWnd->pstWidget[s32Num].stCommon.stAttr.u32WndY = u32WndStart + pstWnd->unPrivate.stCtrlSets.s32Top;
			pstWnd->pstWidget[s32Num].stCommon.stAttr.u32WndWidth = pstWnd->stCommon.stAttr.u32WndWidth -
										pstWnd->unPrivate.stCtrlSets.s32Left -
										pstWnd->unPrivate.stCtrlSets.s32Right;
			pstWnd->pstWidget[s32Num].stCommon.stAttr.u32WndHeight = s32CtlrHeight -
							pstWnd->unPrivate.stCtrlSets.s32Top -
							pstWnd->unPrivate.stCtrlSets.s32Bottom;
#if 0

			u32ChildWndX = ((0 + pstWnd->unPrivate.stCtrlSets.s32Left) * u32WndWidth) / UI_COORD_MAX;
			u32ChildWndY = ((u32WndStart + pstWnd->unPrivate.stCtrlSets.s32Top) * u32WndHeight) / UI_COORD_MAX;
			u32ChildWndWidth = ((pstWnd->stCommon.stAttr.u32WndWidth -
							pstWnd->unPrivate.stCtrlSets.s32Left -
							pstWnd->unPrivate.stCtrlSets.s32Right) * u32WndWidth) / UI_COORD_MAX;
			u32ChildWndHeight = ((s32CtlrHeight -
							pstWnd->unPrivate.stCtrlSets.s32Top -
							pstWnd->unPrivate.stCtrlSets.s32Bottom) * u32WndHeight) / UI_COORD_MAX;
#endif
			u32WndStart +=s32CtlrHeight;
		} else if(pstWnd->unPrivate.stCtrlSets.s32Direction == 2) {

			s32Count = sqrt(pstWnd->s32WidgetNum);
			if((s32Count * s32Count) < pstWnd->s32WidgetNum) {

				s32Count += 1;
			}
			s32CtrlWidth = pstWnd->stCommon.stAttr.u32WndWidth / s32Count;

			/* 计算行数 */
			if(pstWnd->s32WidgetNum <= (s32Count) * (s32Count - 1)) {
				s32CtlrHeight = pstWnd->stCommon.stAttr.u32WndHeight/(s32Count - 1);
			} else {
				s32CtlrHeight = pstWnd->stCommon.stAttr.u32WndHeight / s32Count;
			}


			/* 每过固定的数则转跳下一行*/
			if((s32Num)%(s32Count) != 0 || s32Num == 0) {

#if 1
				pstWnd->pstWidget[s32Num].stCommon.stAttr.u32WndX = u32WndStart + pstWnd->unPrivate.stCtrlSets.s32Left;
				pstWnd->pstWidget[s32Num].stCommon.stAttr.u32WndY = u32WndStartHeight + pstWnd->unPrivate.stCtrlSets.s32Top;
#else
				pstWnd->pstWidget[s32Num].stCommon.stAttr.u32WndX = pstWnd->stCommon.stAttr.u32WndX + u32WndStart + pstWnd->unPrivate.stCtrlSets.s32Left;
				pstWnd->pstWidget[s32Num].stCommon.stAttr.u32WndY = pstWnd->stCommon.stAttr.u32WndY + u32WndStartHeight + pstWnd->unPrivate.stCtrlSets.s32Top;
#endif
				pstWnd->pstWidget[s32Num].stCommon.stAttr.u32WndWidth = s32CtrlWidth -
															pstWnd->unPrivate.stCtrlSets.s32Left -
															pstWnd->unPrivate.stCtrlSets.s32Right;
				pstWnd->pstWidget[s32Num].stCommon.stAttr.u32WndHeight = s32CtlrHeight -
								pstWnd->unPrivate.stCtrlSets.s32Top -
								pstWnd->unPrivate.stCtrlSets.s32Bottom;
				u32WndStart +=s32CtrlWidth;
			} else {

				u32WndStart = 0;
				u32WndStartHeight +=s32CtlrHeight;
#if 1
				pstWnd->pstWidget[s32Num].stCommon.stAttr.u32WndX = u32WndStart + pstWnd->unPrivate.stCtrlSets.s32Left;
				pstWnd->pstWidget[s32Num].stCommon.stAttr.u32WndY = u32WndStartHeight + pstWnd->unPrivate.stCtrlSets.s32Top;
#else
				pstWnd->pstWidget[s32Num].stCommon.stAttr.u32WndX = pstWnd->stCommon.stAttr.u32WndX + u32WndStart + pstWnd->unPrivate.stCtrlSets.s32Left;
				pstWnd->pstWidget[s32Num].stCommon.stAttr.u32WndY = pstWnd->stCommon.stAttr.u32WndY + u32WndStartHeight + pstWnd->unPrivate.stCtrlSets.s32Top;
#endif
				pstWnd->pstWidget[s32Num].stCommon.stAttr.u32WndWidth = s32CtrlWidth -
											pstWnd->unPrivate.stCtrlSets.s32Left -
											pstWnd->unPrivate.stCtrlSets.s32Right;
				pstWnd->pstWidget[s32Num].stCommon.stAttr.u32WndHeight = s32CtlrHeight -
								pstWnd->unPrivate.stCtrlSets.s32Top -
								pstWnd->unPrivate.stCtrlSets.s32Bottom;
				u32WndStart +=s32CtrlWidth;


			}


		}else if(pstWnd->unPrivate.stCtrlSets.s32Direction == 3) {
				s32CtlrHeight = pstWnd->unPrivate.stCtrlSets.s32Height;

			pstWnd->pstWidget[s32Num].stCommon.stAttr.u32WndX = 0 + pstWnd->unPrivate.stCtrlSets.s32Left;
			pstWnd->pstWidget[s32Num].stCommon.stAttr.u32WndY = u32WndStart + pstWnd->unPrivate.stCtrlSets.s32Top;
			pstWnd->pstWidget[s32Num].stCommon.stAttr.u32WndWidth = pstWnd->stCommon.stAttr.u32WndWidth -
										pstWnd->unPrivate.stCtrlSets.s32Left -
										pstWnd->unPrivate.stCtrlSets.s32Right;
			pstWnd->pstWidget[s32Num].stCommon.stAttr.u32WndHeight = s32CtlrHeight -
							pstWnd->unPrivate.stCtrlSets.s32Top -
							pstWnd->unPrivate.stCtrlSets.s32Bottom;

			u32WndStart +=s32CtlrHeight;
		}else {
			QLOG(ERR, "集合控件的排列方式错误\n");
			return -1;
		}
#if 0
		WND_WIDGET_CreateSwitch(&pstWnd->pstWidget[s32Num], pstWnd->stCommon.stAttr.u32ParentWndId,
									u32ChildWndX,
									u32ChildWndY,
									u32ChildWndWidth,
									u32ChildWndHeight);
#endif
		WND_WIDGET_Create(&pstWnd->pstWidget[s32Num], WndMenuList);
		//WND_WIDGET_Create(&pstWnd->pstWidget[s32Num], pstWnd->stCommon.stAttr.u32ParentWndId);

	}

	return WndMenuList;
}


void WND_WIDGET_DestroyCtrlSets(WND_WIDGET_S *pstWnd)
{


	int s32Num;

	for(s32Num = 0; s32Num < pstWnd->s32WidgetNum; s32Num++) {

		WND_WIDGET_Destroy(&pstWnd->pstWidget[s32Num]);

	}

}






/*!
 * 创建一个部件容器，可以在上面创建其他部件
 * @return  创建的部件容器的窗口id
 * @param pstWnd 部件容器的句柄
 * @param u32WndHeight部件容器的真实高度
 * @param u32WndWidth 部件容器的真实宽度
 * @param u32WndX 部件容器的真实x坐标
 * @param u32WndY 部件容器的真实y坐标
 * @see
 */
unsigned int WND_WIDGET_CreateLayout(WND_WIDGET_S *pstWnd,
									unsigned int u32WndX,
									unsigned int u32WndY,
									unsigned int u32WndWidth,
									unsigned int u32WndHeight)


{
	int s32Num;
	//int s32CtrlWidth;
	//int s32CtlrHeight;
	//unsigned int u32WndStart = 0;
	unsigned int WndMenuList;

	WndMenuList = CreateWindow(CTRL_SCROLLWND,
								"",
								pstWnd->stCommon.stAttr.u64Style,
								pstWnd->stCommon.stAttr.u32Id,
								u32WndX,
								u32WndY,
								u32WndWidth,
								u32WndHeight,
								pstWnd->stCommon.stAttr.u32ParentWndId,
								0);





	SetWindowAdditionalData(WndMenuList, (DWORD)pstWnd);

	MINI_INTF_ScrollCtrlSetCententSize(WndMenuList, 0, 0);

	if(pstWnd->stCommon.stFops.CallBack) {

		/* 设置回调函数*/
		//SendMessage (WndMenuList, SVM_SETCONTAINERPROC, 0, (LPARAM)pstWnd->stCommon.stFops.CallBackByVoid );
	}




	for(s32Num = 0; s32Num < pstWnd->s32WidgetNum; s32Num++) {
		//pstWnd->pstWidget[s32Num].stCommon.stAttr.u32WndX = 0;
		//pstWnd->pstWidget[s32Num].stCommon.stAttr.u32WndY = u32WndStart;
		//pstWnd->pstWidget[s32Num].stCommon.stAttr.u32WndWidth = pstWnd->stCommon.stAttr.u32WndWidth;
		//pstWnd->pstWidget[s32Num].stCommon.stAttr.u32WndHeight = s32CtlrHeight;
		//WND_WIDGET_Create(&pstWnd->pstWidget[s32Num], WndMenuList);
		WND_WIDGET_CreateSwitch(&pstWnd->pstWidget[s32Num], WndMenuList,
									(pstWnd->pstWidget[s32Num].stCommon.stAttr.u32WndX*u32WndWidth) / UI_COORD_MAX,
									(pstWnd->pstWidget[s32Num].stCommon.stAttr.u32WndY*u32WndHeight) / UI_COORD_MAX,
									(pstWnd->pstWidget[s32Num].stCommon.stAttr.u32WndWidth*u32WndWidth) / UI_COORD_MAX,
									(pstWnd->pstWidget[s32Num].stCommon.stAttr.u32WndHeight*u32WndHeight) / UI_COORD_MAX);
	}

	return WndMenuList;
}


/*!
 * 销毁一个部件容器
 * @param pstWnd 部件容器的窗口句柄
 * @see
 */
void WND_WIDGET_DestroyLayout(WND_WIDGET_S *pstWnd)
{
	int s32Num;
	for(s32Num = 0; s32Num < pstWnd->s32WidgetNum; s32Num++) {
		WND_WIDGET_Destroy(&pstWnd->pstWidget[s32Num]);
	}

}








/*!
 * 创建双图片按钮
 * @return  创建的双图片按钮的窗口id
 * @param pstWnd 双图片按钮的句柄
 * @param u32WndHeight双图片按钮的真实高度
 * @param u32WndWidth 双图片按钮的真实宽度
 * @param u32WndX 双图片按钮的真实x坐标
 * @param u32WndY 双图片按钮的真实y坐标
 * @see
 */
unsigned int WND_WIDGET_CreateDoublePictureButtonWnd(WND_WIDGET_S *pstWnd,
									unsigned int u32WndX,
									unsigned int u32WndY,
									unsigned int u32WndWidth,
									unsigned int u32WndHeight)
{
	unsigned int u32WndId;

	HDC u32Hdc = GetDC(pstWnd->stCommon.stAttr.u32ParentWndId);

	LoadBitmap(u32Hdc, &pstWnd->unPrivate.stDouPicButt.stBitMap , pstWnd->unPrivate.stDouPicButt.s8MapPath);
	LoadBitmap(u32Hdc, &pstWnd->unPrivate.stDouPicButt.stBitMapCursel , pstWnd->unPrivate.stDouPicButt.s8MapPathCursel);

	pstWnd->stCommon.stAttr.u64Style |= SS_BITMAP | SS_NOTIFY | SS_CENTERIMAGE;



	pstWnd->unPrivate.stDouPicButt.u32WndIdCursel = MINI_INTF_CreateWnd(CTRL_STATIC,
									pstWnd->stCommon.stAttr.s8Name,
									pstWnd->stCommon.stAttr.u64Style,
									pstWnd->stCommon.stAttr.u32Id,
									u32WndX, u32WndY, u32WndWidth, u32WndHeight,
									pstWnd->stCommon.stAttr.u32ParentWndId,
									(DWORD)&pstWnd->unPrivate.stDouPicButt.stBitMapCursel,
									pstWnd->stCommon.stFops.CallBackByVoid);
	ShowWindow(pstWnd->unPrivate.stDouPicButt.u32WndIdCursel, SW_HIDE);

	pstWnd->stCommon.stAttr.u32WndId = u32WndId = MINI_INTF_CreateWnd(CTRL_STATIC,
									pstWnd->stCommon.stAttr.s8Name,
									pstWnd->stCommon.stAttr.u64Style,
									pstWnd->stCommon.stAttr.u32Id,
									u32WndX, u32WndY, u32WndWidth, u32WndHeight,
									pstWnd->stCommon.stAttr.u32ParentWndId,
									(DWORD)&pstWnd->unPrivate.stDouPicButt.stBitMap,
									pstWnd->stCommon.stFops.CallBackByVoid);
	SetWindowBkColor(pstWnd->unPrivate.stDouPicButt.u32WndIdCursel, WND_WIDGET_GetMiniguiColour(WND_WIDGET_GetBkColour(pstWnd)));


	SetWindowAdditionalData(pstWnd->unPrivate.stDouPicButt.u32WndIdCursel, (DWORD)pstWnd);
	SetWindowAdditionalData(u32WndId, (DWORD)pstWnd);
	ReleaseDC(u32Hdc);

	return u32WndId;

}


/*!
 * 切换双图片按钮的高亮
 * @param u32Wnd 要切换的双图片按钮窗口id
 * @see
 */
int WND_WIDGET_DoublePictureButtonShow(unsigned int u32Wnd)
{
	WND_WIDGET_S *pstWnd = (WND_WIDGET_S *)GetWindowAdditionalData(u32Wnd);
	if(pstWnd)	{
		if(u32Wnd == pstWnd->stCommon.stAttr.u32WndId) {
			ShowWindow(pstWnd->unPrivate.stDouPicButt.u32WndIdCursel, SW_SHOW);
			ShowWindow(u32Wnd, SW_HIDE);
			pstWnd->unPrivate.stDouPicButt.bCursel = true;
		} else {
			ShowWindow(pstWnd->stCommon.stAttr.u32WndId, SW_SHOW);
			ShowWindow(u32Wnd, SW_HIDE);
			pstWnd->unPrivate.stDouPicButt.bCursel = false;
		}
	} else {
		QLOG(TDBG, "双图片按钮没有附加数据\n");
		return -1;
	}
	return 0;
}

/*!
 * 设置双图片按钮的高亮图片
 * @param s32Show 0.不高亮 1.高亮
 * @param u32Wnd 要设置的双图片按钮的窗口id
 * @see
 */
void WND_WIDGET_DoublePictureButtonSetShow(unsigned int u32Wnd, int s32Show)
{
	WND_WIDGET_S *pstWnd = (WND_WIDGET_S *)GetWindowAdditionalData(u32Wnd);
	if(pstWnd)	{
		if(s32Show == 1) {
			ShowWindow(pstWnd->unPrivate.stDouPicButt.u32WndIdCursel, SW_SHOW);
			ShowWindow(pstWnd->stCommon.stAttr.u32WndId, SW_HIDE);
			pstWnd->unPrivate.stDouPicButt.bCursel = true;
		} else {
			ShowWindow(pstWnd->stCommon.stAttr.u32WndId, SW_SHOW);
			ShowWindow(pstWnd->unPrivate.stDouPicButt.u32WndIdCursel, SW_HIDE);
			pstWnd->unPrivate.stDouPicButt.bCursel = false;
		}
	} else {
		QLOG(TDBG, "没有附加数据\n");
	}

}


/*!
 * 刷新一个双图片按钮的当前显示图片
 * @return  0.成功 -1 失败
 * @param u32Wnd 要刷新的双图片按钮的窗口id
 * @see
 */
int WND_WIDGET_FlushDoublePictureButtonCursel(unsigned int u32Wnd)
{
	WND_WIDGET_S *pstWnd = NULL;
	WND_WIDGET_S *pstParentWnd = NULL;
	int s32Num;

	pstWnd = (WND_WIDGET_S*)GetWindowAdditionalData(u32Wnd);
	pstParentWnd = (WND_WIDGET_S*)GetWindowAdditionalData(GetParent(u32Wnd));
	if(pstWnd == NULL) {
		SLOG(ERR, "获取窗口结构体失败\n");
		return -1;
	}
	for(s32Num = 0; s32Num < pstParentWnd->s32WidgetNum; s32Num++) {
		if(pstParentWnd->pstWidget[s32Num].unPrivate.stDouPicButt.bCursel == true &&
			pstParentWnd->pstWidget[s32Num].stCommon.stAttr.u32WndId != u32Wnd &&
			u32Wnd != pstParentWnd->pstWidget[s32Num].unPrivate.stDouPicButt.u32WndIdCursel) {
			WND_WIDGET_DoublePictureButtonSetShow(pstParentWnd->pstWidget[s32Num].stCommon.stAttr.u32WndId, 0);
		} else if(pstParentWnd->pstWidget[s32Num].unPrivate.stDouPicButt.bCursel == false &&
			pstParentWnd->pstWidget[s32Num].stCommon.stAttr.u32WndId == u32Wnd){
			WND_WIDGET_DoublePictureButtonSetShow(pstParentWnd->pstWidget[s32Num].stCommon.stAttr.u32WndId, 1);
		}
	}
	return 0;
}



/*!
 * 设置按钮的高亮选项
 * @return  0.成功 -1.失败
 * @param s32Show 0.不高亮 1.高亮
 * @param u32Wnd 要刷新的按钮的窗口id
 * @see
 */
int WND_WIDGET_ButtonSetCursel(unsigned int u32Wnd, int s32Show)
{
	WND_WIDGET_S *pstWnd = (WND_WIDGET_S *)GetWindowAdditionalData(u32Wnd);
	if(pstWnd)	{
		if(s32Show == 1) {
			SetWindowBkColor(u32Wnd, WND_WIDGET_GetMiniguiColour(pstWnd->unPrivate.stButton.enCurselBkColor));
			WND_WIDGET_SetFontcolor(pstWnd, pstWnd->unPrivate.stButton.enCurselFontColor);
			pstWnd->unPrivate.stButton.bCursel = true;
		} else {
			WND_WIDGET_EnbleBkColour(pstWnd);
			WND_WIDGET_EnbleFontColour(pstWnd);
			pstWnd->unPrivate.stButton.bCursel = false;
		}
	} else {
		QLOG(TDBG, "没有附加数据\n");
		return -1;
	}
	UpdateWindow(u32Wnd, TRUE);
	return 0;
}


/*!
 * 属性当前按钮的高亮，只对在同一个子部件下的按钮有效果
 * @return  0.成功 -1.失败
 * @param u32Wnd 要刷新的按钮窗口id
 * @see
 */
int WND_WIDGET_FlushButtonCursel(unsigned int u32Wnd)
{

	WND_WIDGET_S *pstParentWnd = NULL;
	int s32Num;

	//pstWnd = (WND_WIDGET_S*)GetWindowAdditionalData(u32Wnd);
	pstParentWnd = (WND_WIDGET_S*)GetWindowAdditionalData(GetParent(u32Wnd));

	if(pstParentWnd) {
		for(s32Num = 0; s32Num < pstParentWnd->s32WidgetNum; s32Num++) {
			if(pstParentWnd->pstWidget[s32Num].unPrivate.stButton.bCursel == true &&
				pstParentWnd->pstWidget[s32Num].stCommon.stAttr.u32WndId != u32Wnd) {
				WND_WIDGET_ButtonSetCursel(pstParentWnd->pstWidget[s32Num].stCommon.stAttr.u32WndId, 0);
			} else if(pstParentWnd->pstWidget[s32Num].unPrivate.stButton.bCursel == false &&
				pstParentWnd->pstWidget[s32Num].stCommon.stAttr.u32WndId == u32Wnd){
				WND_WIDGET_ButtonSetCursel(u32Wnd, 1);
			}
		}
	} else {
		QLOG(ERR, "未找到窗口附加数据\n");
		return -1;
	}

	return 0;

}

/*!
 * 创建下拉框
 * @return  创建的下拉框的窗口id
 * @param pstWnd 下拉框的句柄
 * @param u32WndHeight 下拉框的真实高度
 * @param u32WndWidth 下拉框的真实宽度
 * @param u32WndX 下拉框的真实x坐标
 * @param u32WndY 下拉框的真实y坐标
 * @see
 */
unsigned int WND_WIDGET_CreateDropDownWnd(WND_WIDGET_S *pstWnd,
									unsigned int u32WndX,
									unsigned int u32WndY,
									unsigned int u32WndWidth,
									unsigned int u32WndHeight)

{
	unsigned int u32WndId;
	int s32Num;
	SLOG(TDBG, "下拉框\n");
	pstWnd->stCommon.stAttr.u64Style |= CBS_NOTIFY;

	u32WndId = MINI_INTF_CreateWndDropDownList(2,
									pstWnd->stCommon.stAttr.u64Style,
									pstWnd->stCommon.stAttr.u32Id,
									u32WndX, u32WndY, u32WndWidth, u32WndHeight,
									pstWnd->stCommon.stAttr.u32ParentWndId,
									(pstWnd->unPrivate.stDropDown.s32ListHeight * stGlbMainWndHandle.s32ScreenHeight) / UI_COORD_MAX,
									pstWnd->stCommon.stFops.CallBackByVoid);

	for(s32Num = 0; s32Num < pstWnd->unPrivate.stDropDown.s32Num; s32Num++) {
		MINI_INTF_DropDownAddStr(u32WndId, pstWnd->unPrivate.stDropDown.pstItm[s32Num].ps8Name);
	}


	return u32WndId;
}



/*!
 * 创建编辑框
 * @return  创建的编辑框的窗口id
 * @param pstWnd 编辑框的句柄
 * @param u32WndHeight 编辑框的真实高度
 * @param u32WndWidth 编辑框的真实宽度
 * @param u32WndX 编辑框的真实x坐标
 * @param u32WndY 编辑框的真实y坐标
 * @see
 */
unsigned int WND_WIDGET_CreateEditWnd(WND_WIDGET_S *pstWnd,
									unsigned int u32WndX,
									unsigned int u32WndY,
									unsigned int u32WndWidth,
									unsigned int u32WndHeight)

{
	unsigned int u32WndId;
	if(pstWnd->unPrivate.stEdit.u32Type > 2) {
		QLOG(ERR, "编辑框的类型错误\n");
	}

	u32WndId = MINI_INTF_CreateWndEdit(pstWnd->unPrivate.stEdit.u32Type,
				pstWnd->stCommon.stAttr.u64Style,
				pstWnd->stCommon.stAttr.u32Id,
				u32WndX, u32WndY, u32WndWidth, u32WndHeight,
				pstWnd->stCommon.stAttr.u32ParentWndId,
				(DWORD)pstWnd,
				pstWnd->stCommon.stFops.CallBackByVoid);



	return u32WndId;
}










/*!
 * 创建一个部件
 * @return  返回创建的部件的窗口id
 * @param pstWnd 部件的句柄
 * @param u32Parent 父窗口id，指出需要在哪个窗口上面创建
 * @param u32WndHeight 部件的真实高
 * @param u32WndWidth 部件的真实宽
 * @param u32WndX 部件的真实x坐标
 * @param u32WndY 部件的真实y坐标
 * @see
 */
unsigned int WND_WIDGET_CreateSwitch(WND_WIDGET_S *pstWnd, unsigned int u32Parent,
									unsigned int u32WndX,
									unsigned int u32WndY,
									unsigned int u32WndWidth,
									unsigned int u32WndHeight)
{
	unsigned int u32Wnd = 0;
	WIDGET_COMMON_S *pstCommon = &pstWnd->stCommon;
	WND_ATTR_S *pstAttr = &pstCommon->stAttr;
	WND_FOPS_S *pstFops = &pstCommon->stFops;


	if(pstWnd->stCommon.stSta.bCreate == true) {
		QLOG(WRN, "[%s]已经被创建，无需重复创建\n", pstAttr->s8Name);
		return -1;
	}
	WND_WIDGET_StlySwitch(pstWnd, u32Parent);

	switch(pstWnd->enType) {
		case WND_WIDGET_TYPE_MAIN_E:{
			sem_init(&pstWnd->unPrivate.stMain.stWait, 0, 0);

			if(pthread_create(&pstWnd->unPrivate.stMain.stPid, NULL, WND_WIDGET_CreateMain, (void*)pstWnd)) {
				QLOG(ERR, "创建 [%s] 窗口线程失败\n", pstAttr->s8Name);
				return 0;
			}else {
				//线程设置成自动销毁
				if(pthread_detach(pstWnd->unPrivate.stMain.stPid)) {
					QLOG(ERR, "[%s] 线程设置成自动销毁失败\n", pstAttr->s8Name);
					return 0;
				}
				sem_wait(&pstWnd->unPrivate.stMain.stWait);
				sem_destroy(&pstWnd->unPrivate.stMain.stWait);
				break;
			}
		}
		break;
		case WND_WIDGET_TYPE_BUTTON_E: {

			pstAttr->u32WndId = WND_WIDGET_CreateButton(pstWnd,
								u32WndX,
								u32WndY,
								u32WndWidth,
								u32WndHeight);
		}
		break;
		case WND_WIDGET_TYPE_PICTURE_BUTTON_E: {
			pstAttr->u32WndId = WND_WIDGET_CreatePictureButton(pstWnd,
								u32WndX,
								u32WndY,
								u32WndWidth,
								u32WndHeight);
		}
		break;
		case WND_WIDGET_TYPE_MULTI_BUTTON_E: {
			pstAttr->u32WndId = WND_WIDGET_CreateMultiButton(pstWnd,
								u32WndX,
								u32WndY,
								u32WndWidth,
								u32WndHeight);
		}
		break;
		case WND_WIDGET_TYPE_RADIO_BUTTON_E: {
			pstAttr->u32WndId = WND_WIDGET_CreateRadioButton(pstWnd,
								u32WndX,
								u32WndY,
								u32WndWidth,
								u32WndHeight);
		}
		break;
		case WND_WIDGET_TYPE_STATIC_PICTURE_E: {
			pstAttr->u32WndId = WND_WIDGET_CreateStaticPictureWnd(pstWnd,
								u32WndX,
								u32WndY,
								u32WndWidth,
								u32WndHeight);

		}
		break;
		case WND_WIDGET_TYPE_STATIC_TEXT_E: {
			pstAttr->u32WndId = MINI_INTF_CreateStaticTextWnd(pstAttr->s8Name,
								pstAttr->u64Style,
								pstAttr->u32Id,
								u32WndX,
								u32WndY,
								u32WndWidth,
								u32WndHeight,
								pstAttr->u32ParentWndId,
								(DWORD)pstWnd,
								pstFops->CallBackByVoid);

		}
		break;
		case WND_WIDGET_TYPE_SCROLL_E: {
			pstAttr->u32WndId = WND_WIDGET_CreateListMenu(pstWnd,
								u32WndX,
								u32WndY,
								u32WndWidth,
								u32WndHeight);

		}
		break;

		case WND_WIDGET_TYPE_ATTR_LIST_E: {
			pstAttr->u32WndId = WND_CREATE_AttrPage(pstWnd,
								u32WndX,
								u32WndY,
								u32WndWidth,
								u32WndHeight);
		}
		break;
		case WND_WIDGET_TYPE_DLG_E: {
			pstAttr->u32WndId = WND_WIDGET_CreateDlg(pstWnd,
								u32WndX,
								u32WndY,
								u32WndWidth,
								u32WndHeight);

			/* 对话框不会马上返回，返回这里代表对话框结束了，别的就都没有操作的必要了*/
			pstWnd->stCommon.stSta.bCreate = false;
			return 0;

		}
		case WND_WIDGET_TYPE_ICON_VIEW_E: {
			pstAttr->u32WndId = WND_WIDGET_CreateIconView(pstWnd,
								u32WndX,
								u32WndY,
								u32WndWidth,
								u32WndHeight);
		}
		break;
		case WND_WIDGET_TYPE_CTRL_SETS_E: {
			pstAttr->u32WndId = WND_WIDGET_CreateCtrlSets(pstWnd,
								u32WndX,
								u32WndY,
								u32WndWidth,
								u32WndHeight);
		}
		break;
		case WND_WIDGET_TYPE_LAYOUT_E: {
			pstAttr->u32WndId = WND_WIDGET_CreateLayout(pstWnd,
								u32WndX,
								u32WndY,
								u32WndWidth,
								u32WndHeight);
		}
		break;
		case WND_WIDGET_TYPE_DOUBLE_PIC_BUTT_E: {
			pstAttr->u32WndId = WND_WIDGET_CreateDoublePictureButtonWnd(pstWnd,
											u32WndX,
											u32WndY,
											u32WndWidth,
											u32WndHeight);
		}
		break;
		case WND_WIDGET_TYPE_DROP_DOWN_E: {
			pstAttr->u32WndId = WND_WIDGET_CreateDropDownWnd(pstWnd,
									u32WndX,
									u32WndY,
									u32WndWidth,
									u32WndHeight);
		}
		break;
		case WND_WIDGET_TYPE_EDIT_E: {
			pstAttr->u32WndId = WND_WIDGET_CreateEditWnd(pstWnd,
									u32WndX,
									u32WndY,
									u32WndWidth,
									u32WndHeight);
		}
		break;
		default:
			QLOG(ERR, "非法控件，无法创建\n");
			return -1;
	}

	if(pstAttr->u32WndId == -1) {
		QLOG(ERR, "控件创建返回窗口id出错\n");
		return -1;
	}

	WND_WIDGET_EnbleStly(pstWnd);



	u32Wnd = pstAttr->u32WndId;
	pstWnd->stCommon.stSta.bCreate = true;
	if(pstWnd->enType == WND_WIDGET_TYPE_MAIN_E) {
		if(pstAttr->bShowNow == true) {
			//sleep(3);
			QLOG(TDBG , "显示窗口 [%s]\n", pstWnd->stCommon.stAttr.s8Name);
			ShowWindow(u32Wnd, SW_SHOWNORMAL);
			//UpdateWindow(u32Wnd, TRUE);
		} else {
			QLOG(TDBG , "隐藏窗口 [%s]\n", pstWnd->stCommon.stAttr.s8Name);
			ShowWindow(u32Wnd, SW_HIDE);
		}
	}


	/* 刷新窗口*/
	//UpdateWindow(u32Wnd, TRUE);

	return u32Wnd;

}

/*!
 * 创建一个部件
 * @return  返回创建的部件的窗口id
 * @param pstWnd 要创建的部件的句柄
 * @param u32Parent 父窗口id，指出需要创建在哪个窗口上面
 * @see
 */
unsigned int WND_WIDGET_Create(WND_WIDGET_S *pstWnd, unsigned int u32Parent)
{
	//unsigned int u32Wnd = 0;
	//int s32Num;
	if(pstWnd == NULL) {
		QLOG(ERR, "控件句柄为空\n");
		return -1;
	}

	WIDGET_COMMON_S *pstCommon = &pstWnd->stCommon;
	WND_ATTR_S *pstAttr = &pstCommon->stAttr;
	//WND_FOPS_S *pstFops = &pstCommon->stFops;



#if 0
	unsigned int u32WndX = (pstAttr->u32WndX * stGlbMainWndHandle.s32ScreenWidth +
							UI_COORD_X * stGlbMainWndHandle.s32ScreenWidth) / UI_COORD_MAX;
	unsigned int u32WndY = (pstAttr->u32WndY * stGlbMainWndHandle.s32ScreenHeight +
							UI_COORD_Y * stGlbMainWndHandle.s32ScreenHeight) / UI_COORD_MAX;
	unsigned int u32WndWidth = (pstAttr->u32WndWidth * stGlbMainWndHandle.s32ScreenWidth -
							UI_COORD_WIDTH * stGlbMainWndHandle.s32ScreenWidth) / UI_COORD_MAX - u32WndX;
	unsigned int u32WndHeight = (pstAttr->u32WndHeight * stGlbMainWndHandle.s32ScreenHeight -
							UI_COORD_HEIGHT * stGlbMainWndHandle.s32ScreenHeight) / UI_COORD_MAX - u32WndY;
#else
	unsigned int u32WndX = (pstAttr->u32WndX * stGlbMainWndHandle.s32ScreenWidth) / UI_COORD_MAX;
	unsigned int u32WndY = (pstAttr->u32WndY * stGlbMainWndHandle.s32ScreenHeight) / UI_COORD_MAX;
	unsigned int u32WndWidth = (pstAttr->u32WndWidth * stGlbMainWndHandle.s32ScreenWidth) / UI_COORD_MAX;
	unsigned int u32WndHeight = (pstAttr->u32WndHeight * stGlbMainWndHandle.s32ScreenHeight) / UI_COORD_MAX;

#endif



	return WND_WIDGET_CreateSwitch(pstWnd, u32Parent, u32WndX,u32WndY,u32WndWidth,u32WndHeight);
}



/*!
 * 销毁一个部件，会销毁部件下的所有子部件
 * @param pstWnd 要销毁的部件的句柄
 * @see
 */
void WND_WIDGET_Destroy(WND_WIDGET_S *pstWnd)
{
	int s32Num;
	//QLOG(TDBG, "---------删除[%s]\n", pstWnd->stCommon.stAttr.s8Name);

	/* 删除一个主界面，先将它隐藏*/
	if(pstWnd->enType == WND_WIDGET_TYPE_MAIN_E) {
		//ShowWindow(pstWnd->stCommon.stAttr.u32ParentWndId, SW_SHOW);
		ShowWindow(pstWnd->stCommon.stAttr.u32WndId, SW_HIDE);
	}

	if(pstWnd->pstWidget != NULL && pstWnd->s32WidgetNum > 0) {
		for(s32Num = 0; s32Num < pstWnd->s32WidgetNum; s32Num++) {
			WND_WIDGET_Destroy(&pstWnd->pstWidget[s32Num]);
		}
	}

	if(pstWnd->stCommon.stSta.bCreate == true) {
		//QLOG(TDBG, "删除[%s]\n", pstWnd->stCommon.stAttr.s8Name);


		switch(pstWnd->enType) {
			case WND_WIDGET_TYPE_MAIN_E:
			case WND_WIDGET_TYPE_BUTTON_E:
			case WND_WIDGET_TYPE_MULTI_BUTTON_E:
			case WND_WIDGET_TYPE_RADIO_BUTTON_E:
			case WND_WIDGET_TYPE_STATIC_TEXT_E:
			case WND_WIDGET_TYPE_DROP_DOWN_E:
			case WND_WIDGET_TYPE_EDIT_E:
			case WND_WIDGET_TYPE_ATTR_PAGE_E:
			/* 不需要做特殊处理，直接销毁窗口就行*/
				break;
			case WND_WIDGET_TYPE_PICTURE_BUTTON_E:
				WND_WIDGET_DestroyPictureButton(pstWnd);
				break;
			case WND_WIDGET_TYPE_STATIC_PICTURE_E:
				UnloadBitmap(&pstWnd->unPrivate.stStaticPicture.stBitMap);
				break;
			case WND_WIDGET_TYPE_SCROLL_E:
				WND_CREATE_ListMenuDestroy(pstWnd);
				break;
			case WND_WIDGET_TYPE_ATTR_LIST_E:
				WND_CREATE_AttrPageDestroy(pstWnd);
				break;
			case WND_WIDGET_TYPE_DLG_E:
				WND_WIDGET_DestroyDlg(pstWnd);
				break;
			case WND_WIDGET_TYPE_ICON_VIEW_E:
				WND_WIDGET_DestroyIconView(pstWnd);
				break;
			case WND_WIDGET_TYPE_CTRL_SETS_E:
				WND_WIDGET_DestroyCtrlSets(pstWnd);
				break;
			case WND_WIDGET_TYPE_LAYOUT_E:
				WND_WIDGET_DestroyLayout(pstWnd);
				break;
			default:
				break;
		}


		if(pstWnd->stCommon.stAttr.u32WndId > 0){
			if(pstWnd->enType == WND_WIDGET_TYPE_DLG_E) {
				EndDialog(pstWnd->stCommon.stAttr.u32WndId, 0);
			} else if(pstWnd->enType == WND_WIDGET_TYPE_MAIN_E) {
				MINI_INTF_DestroyMainWnd(pstWnd->stCommon.stAttr.u32WndId);
			}
			/*else if(pstWnd->enType == WND_WIDGET_TYPE_ATTR_PAGE_E ) {
				MINI_INTF_DestroyWnd(pstWnd->stCommon.stAttr.u32WndId);
				pstWnd->stCommon.stSta.bCreate = false;
			}*/
			else {

				MINI_INTF_DestroyWnd(pstWnd->stCommon.stAttr.u32WndId);

			}
		}
		pstWnd->stCommon.stAttr.u32WndId = 0;
		pstWnd->stCommon.stSta.bCreate = false;
	}



}




/*!
 * 按照组编号创建一组部件
 * @return 0.成功 -1.失败
 * @param pstWnd 部件句柄 本接口会搜索这个句柄下的所有子部件，找到所有符合的组编号并创建
 * @param u32Group 窗口组编号
 * @param u32ParentWnd 父窗口id，指出窗口创建在哪个父窗口
 * @see
 */
int WND_WIDGET_CreateChildByGroup(WND_WIDGET_S *pstWnd, unsigned int u32ParentWnd, unsigned int u32Group)
{
	int s32Num;
	if(pstWnd == NULL) {
		QLOG(ERR, "部件结构体为空\n");
		return -1;
	}

	for(s32Num = 0; s32Num < pstWnd->s32WidgetNum; s32Num++) {
		if(pstWnd->pstWidget) {
			if(pstWnd->pstWidget[s32Num].stCommon.stAttr.u32Group == u32Group) {
				WND_WIDGET_Create(&pstWnd->pstWidget[s32Num], u32ParentWnd);
			} else {
				WND_WIDGET_CreateChildByGroup(pstWnd, u32ParentWnd, u32Group);
			}
		}
	}
	QLOG(ERR, "本层为找到指定部件\n");
	return 0;
}



/*!
 * 按照编号创建部件
 * @return 返回创建的窗口id
 * @param pstWnd 部件句柄 本接口会搜索这个句柄下的所有子部件，直到找到符合的id并创建
 * @param u32Id 要创建的部件的编号
 * @param u32ParentWnd 父窗口id，指出窗口创建在哪个父窗口
 * @see
 */
unsigned int WND_WIDGET_CreateById(WND_WIDGET_S *pstWnd, unsigned int u32ParentWnd, unsigned int u32Id)
{
	int s32Num;
	unsigned int u32Wnd = 0;
	if(pstWnd == NULL) {
		QLOG(ERR, "部件结构体为空\n");
		return 0;
	}

	for(s32Num = 0; s32Num < pstWnd->s32WidgetNum; s32Num++) {
		if(pstWnd->pstWidget) {
			if(pstWnd->pstWidget[s32Num].stCommon.stAttr.u32Id == u32Id) {
				return WND_WIDGET_Create(&pstWnd->pstWidget[s32Num], u32ParentWnd);
			} else {
				QLOG(TDBG, "寻找[0x%x]的部件-------\n", u32Id);
				u32Wnd = WND_WIDGET_CreateById(&pstWnd->pstWidget[s32Num], u32ParentWnd, u32Id);
				if(u32Wnd != 0 && u32Wnd != -1) {
					return u32Wnd;
				}
			}
		}
	}

	//QLOG(ERR, "本层为找到指定id [0x%x]的部件\n", u32Id);
	return 0;
}


/*!
 * 按照编号销毁部件
 * @param pstWnd 部件句柄 本接口会搜索这个句柄下的所有子部件，直到找到符合的id并销毁
 * @param u32Id 要创建的部件的编号
 * @see
 */
void WND_WIDGET_DestroyById(WND_WIDGET_S *pstWnd, unsigned int u32Id)
{
	int s32Num;
	if(pstWnd == NULL) {
		QLOG(ERR, "部件结构体为空\n");
		return;
	}

	for(s32Num = 0; s32Num < pstWnd->s32WidgetNum; s32Num++) {
		if(pstWnd->pstWidget) {
			if(pstWnd->pstWidget[s32Num].stCommon.stAttr.u32Id == u32Id) {
				return WND_WIDGET_Destroy(pstWnd);
			} else {
				WND_WIDGET_DestroyById(&pstWnd->pstWidget[s32Num], u32Id);
			}
		}
	}

	return ;
}



